com.google.common.collect.ImmutableSet.Builder#add ( )源码实例Demo

下面列出了com.google.common.collect.ImmutableSet.Builder#add ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Kettle   文件: StandardMessenger.java
public Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(Plugin plugin, String channel) {
    if (plugin == null) {
        throw new IllegalArgumentException("Plugin cannot be null");
    }
    validateChannel(channel);

    synchronized (incomingLock) {
        Set<PluginMessageListenerRegistration> registrations = incomingByPlugin.get(plugin);

        if (registrations != null) {
            Builder<PluginMessageListenerRegistration> builder = ImmutableSet.builder();

            for (PluginMessageListenerRegistration registration : registrations) {
                if (registration.getChannel().equals(channel)) {
                    builder.add(registration);
                }
            }

            return builder.build();
        } else {
            return ImmutableSet.of();
        }
    }
}
 
源代码2 项目: Signals   文件: PacketAddOrUpdateTrain.java
@Override
public void fromBytes(ByteBuf b){
    trainID = b.readInt();

    int ids = b.readInt();
    PacketBuffer pb = new PacketBuffer(b);
    Builder<UUID> cartIDs = new ImmutableSet.Builder<>();
    for(int i = 0; i < ids; i++) {
        cartIDs.add(pb.readUniqueId());
    }
    this.cartIDs = cartIDs.build();

    int posCount = b.readInt();
    Builder<MCPos> positions = new ImmutableSet.Builder<>();
    for(int i = 0; i < posCount; i++) {
        positions.add(new MCPos(b));
    }
    this.positions = positions.build();
}
 
源代码3 项目: Mixin   文件: SupportedOptions.java
/**
 * Return all supported options
 */
public static Set<String> getAllOptions() {
    Builder<String> options = ImmutableSet.<String>builder();
    options.add(
        SupportedOptions.TOKENS,
        SupportedOptions.OUT_REFMAP_FILE,
        SupportedOptions.DISABLE_TARGET_VALIDATOR,
        SupportedOptions.DISABLE_TARGET_EXPORT,
        SupportedOptions.DISABLE_OVERWRITE_CHECKER,
        SupportedOptions.OVERWRITE_ERROR_LEVEL,
        SupportedOptions.DEFAULT_OBFUSCATION_ENV,
        SupportedOptions.DEPENDENCY_TARGETS_FILE,
        SupportedOptions.MAPPING_TYPES,
        SupportedOptions.PLUGIN_VERSION
    );
    options.addAll(
        ObfuscationServices.getInstance().getSupportedOptions()
    );
    return options.build();
}
 
源代码4 项目: batfish   文件: CumulusNcluConfiguration.java
private void convertLoopback() {
  Optional.ofNullable(_interfaces.get(LOOPBACK_INTERFACE_NAME))
      .ifPresent(iface -> populateLoInInterfacesToLoopback(iface, _loopback));

  org.batfish.datamodel.Interface newIface = createVIInterfaceForLo();

  if (!_loopback.getAddresses().isEmpty()) {
    newIface.setAddress(_loopback.getAddresses().get(0));
  }
  Builder<ConcreteInterfaceAddress> allAddresses = ImmutableSet.builder();
  allAddresses.addAll(_loopback.getAddresses());
  if (_loopback.getClagVxlanAnycastIp() != null) {
    // Just assume CLAG is correctly configured and comes up
    allAddresses.add(
        ConcreteInterfaceAddress.create(
            _loopback.getClagVxlanAnycastIp(), Prefix.MAX_PREFIX_LENGTH));
  }
  newIface.setAllAddresses(allAddresses.build());
  _c.getAllInterfaces().put(LOOPBACK_INTERFACE_NAME, newIface);
}
 
源代码5 项目: gss.gwt   文件: GssResourceGenerator.java
private Set<String> getPermutationsConditions(ResourceContext context,
    List<String> permutationAxes) {
  Builder<String> setBuilder = ImmutableSet.builder();
  PropertyOracle oracle = context.getGeneratorContext().getPropertyOracle();

  for (String permutationAxis : permutationAxes) {
    String propValue = null;
    try {
      SelectionProperty selProp = oracle.getSelectionProperty(null,
          permutationAxis);
      propValue = selProp.getCurrentValue();
    } catch (BadPropertyValueException e) {
      try {
        ConfigurationProperty confProp = oracle.getConfigurationProperty(permutationAxis);
        propValue = confProp.getValues().get(0);
      } catch (BadPropertyValueException e1) {
        e1.printStackTrace();
      }
    }

    if (propValue != null) {
      setBuilder.add(permutationAxis + ":" + propValue);
    }
  }
  return setBuilder.build();
}
 
源代码6 项目: buck   文件: DefaultProjectFilesystemFactory.java
private static void addPathMatcherRelativeToRepo(
    Path root, Builder<PathMatcher> builder, Path pathToAdd) {
  if (!pathToAdd.isAbsolute()
      || pathToAdd.normalize().startsWith(root.toAbsolutePath().normalize())) {
    if (pathToAdd.isAbsolute()) {
      pathToAdd = root.relativize(pathToAdd);
    }
    builder.add(RecursiveFileMatcher.of(RelPath.of(pathToAdd)));
  }
}
 
源代码7 项目: Kettle   文件: CraftEnderDragon.java
public Set<ComplexEntityPart> getParts() {
    Builder<ComplexEntityPart> builder = ImmutableSet.builder();

    for (MultiPartEntityPart part : getHandle().dragonPartArray) {
        builder.add((ComplexEntityPart) part.getBukkitEntity());
    }

    return builder.build();
}
 
源代码8 项目: cloud-opensource-java   文件: LinkageMonitor.java
/**
 * Returns a message on {@code snapshotSymbolProblems} that do not exist in {@code
 * baselineProblems}.
 */
@VisibleForTesting
static String messageForNewErrors(
    ImmutableSetMultimap<SymbolProblem, ClassFile> snapshotSymbolProblems,
    Set<SymbolProblem> baselineProblems,
    ClassPathResult classPathResult) {
  Set<SymbolProblem> newProblems =
      Sets.difference(snapshotSymbolProblems.keySet(), baselineProblems);
  StringBuilder message =
      new StringBuilder("Newly introduced problem" + (newProblems.size() > 1 ? "s" : "") + ":\n");
  Builder<ClassPathEntry> problematicJars = ImmutableSet.builder();
  for (SymbolProblem problem : newProblems) {
    message.append(problem + "\n");

    // This is null for ClassNotFound error.
    ClassFile containingClass = problem.getContainingClass();
    if (containingClass != null) {
      problematicJars.add(containingClass.getClassPathEntry());
    }

    for (ClassFile classFile : snapshotSymbolProblems.get(problem)) {
      message.append(
          String.format(
              "  referenced from %s (%s)\n",
              classFile.getBinaryName(), classFile.getClassPathEntry()));
      problematicJars.add(classFile.getClassPathEntry());
    }
  }

  message.append("\n");
  message.append(classPathResult.formatDependencyPaths(problematicJars.build()));

  return message.toString();
}
 
源代码9 项目: microorm   文件: ReflectiveDaoAdapter.java
private static <T> ImmutableSet<T> findDuplicates(T[] array) {
  final Builder<T> result = ImmutableSet.builder();
  final Set<T> uniques = Sets.newHashSet();

  for (T element : array) {
    if (!uniques.add(element)) {
      result.add(element);
    }
  }

  return result.build();
}
 
源代码10 项目: dremio-oss   文件: JdbcAssert.java
static Set<String> toStringSet(ResultSet resultSet) throws SQLException {
  Builder<String> builder = ImmutableSet.builder();
  final List<Ord<String>> columns = columnLabels(resultSet);
  while (resultSet.next()) {
    StringBuilder buf = new StringBuilder();
    for (Ord<String> column : columns) {
      buf.append(column.i == 1 ? "" : "; ").append(column.e).append("=").append(resultSet.getObject(column.i));
    }
    builder.add(buf.toString());
    buf.setLength(0);
  }
  return builder.build();
}
 
源代码11 项目: Thermos   文件: CraftEnderDragon.java
public Set<ComplexEntityPart> getParts() {
    Builder<ComplexEntityPart> builder = ImmutableSet.builder();

    for (EntityDragonPart part : getHandle().dragonPartArray) {
        builder.add((ComplexEntityPart) part.getBukkitEntity());
    }

    return builder.build();
}
 
源代码12 项目: gama   文件: SymbolProto.java
public SymbolProto(final Class clazz, final boolean hasSequence, final boolean hasArgs, final int kind,
		final boolean doesNotHaveScope, final FacetProto[] possibleFacets, final String omissible,
		final String[] contextKeywords, final int[] parentKinds, final boolean isRemoteContext,
		final boolean isUniqueInContext, final boolean nameUniqueInContext, final ISymbolConstructor constr,
		final IValidator validator, final SymbolSerializer serializer, final String name, final String plugin) {
	super(name, clazz, plugin);
	factory = DescriptionFactory.getFactory(kind);
	this.validator = validator;
	this.serializer = serializer;
	constructor = constr;
	this.isRemoteContext = isRemoteContext;
	this.hasSequence = hasSequence;
	this.isPrimitive = IKeyword.PRIMITIVE.equals(name);
	this.hasArgs = hasArgs;
	this.omissibleFacet = omissible;
	this.isUniqueInContext = isUniqueInContext;
	this.kind = kind;
	this.isVar = ISymbolKind.Variable.KINDS.contains(kind);
	this.hasScope = !doesNotHaveScope;
	if (possibleFacets != null) {
		final Builder<String> builder = ImmutableSet.builder();
		this.possibleFacets = GamaMapFactory.createUnordered();
		for (final FacetProto f : possibleFacets) {
			this.possibleFacets.put(f.name, f);
			f.setOwner(getTitle());
			if (!f.optional) {
				builder.add(f.name);
			}
		}
		mandatoryFacets = builder.build();
	} else {
		this.possibleFacets = null;
		mandatoryFacets = null;
	}
	this.contextKeywords = ImmutableSet.copyOf(contextKeywords);
	Arrays.fill(this.contextKinds, false);
	for (final int i : parentKinds) {
		contextKinds[i] = true;
	}
}
 
源代码13 项目: james-project   文件: GetAnnotationCommandParser.java
private void consumeKeys(ImapRequestLineReader requestReader, GetAnnotationRequest.Builder builder) throws DecodingException {
    Builder<MailboxAnnotationKey> keys = ImmutableSet.builder();

    do {
        keys.add(new MailboxAnnotationKey(requestReader.atom()));
    } while (requestReader.nextWordChar() != ')');

    builder.keys(keys.build());

    requestReader.consumeChar(')');
    requestReader.eol();
}
 
源代码14 项目: swellrt   文件: SearchServiceTest.java
public Matcher<Map<ParamsProperty, Object>> matchesSearchResult(final String query,
    final WaveId waveId, final String title, final ParticipantId author,
    final Set<ParticipantId> participants, final int unreadCount, final int blipCount) {
  return new BaseMatcher<Map<ParamsProperty, Object>>() {
    @SuppressWarnings("unchecked")
    @Override
    public boolean matches(Object item) {
      Map<ParamsProperty, Object> map = (Map<ParamsProperty, Object>) item;
      assertTrue(map.containsKey(ParamsProperty.SEARCH_RESULTS));

      Object resultsObj = map.get(ParamsProperty.SEARCH_RESULTS);
      SearchResult results = (SearchResult) resultsObj;

      assertEquals(query, results.getQuery());
      assertEquals(1, results.getNumResults());

      Digest digest = results.getDigests().get(0);
      assertEquals(title, digest.getTitle());
      assertEquals(ApiIdSerializer.instance().serialiseWaveId(waveId), digest.getWaveId());

      Builder<ParticipantId> participantIds = ImmutableSet.builder();
      for (String name : digest.getParticipants()) {
        participantIds.add(ParticipantId.ofUnsafe(name));
      }
      assertEquals(participants, participantIds.build());

      assertEquals(unreadCount, digest.getUnreadCount());
      assertEquals(blipCount, digest.getBlipCount());
      return true;
    }

    @Override
    public void describeTo(Description description) {
      description.appendText("Check digests match expected data");
    }
  };
}
 
源代码15 项目: stratio-cassandra   文件: Directories.java
public TrueFilesSizeVisitor()
{
    super();
    Builder<String> builder = ImmutableSet.builder();
    for (File file: sstableLister().listFiles())
        builder.add(file.getName());
    alive = builder.build();
}
 
源代码16 项目: bgpcep   文件: AbstractOffsetMap.java
public final T with(final K key) {
    // TODO: we could make this faster if we had an array-backed Set and requiring
    //       the caller to give us the result of offsetOf() -- as that indicates
    //       where to insert the new routerId while maintaining the sorted nature
    //       of the array
    final Builder<K> builder = ImmutableSet.builderWithExpectedSize(size() + 1);
    builder.add(keys);
    builder.add(key);
    return instanceForKeys(builder.build());
}
 
源代码17 项目: yangtools   文件: BitsSerializationTest.java
private static ImmutableSet<String> fillBits(final int size) {
    final Builder<String> builder = ImmutableSet.builderWithExpectedSize(size);
    for (int i = 0; i < size; ++i) {
        builder.add(Integer.toHexString(i));
    }
    final ImmutableSet<String> ret = builder.build();
    Assert.assertEquals(size, ret.size());
    return ret;
}
 
源代码18 项目: yangtools   文件: KeyStatementSupport.java
@Override
public ImmutableSet<QName> parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
    final Builder<QName> builder = ImmutableSet.builder();
    int tokens = 0;
    for (String keyToken : LIST_KEY_SPLITTER.split(value)) {
        builder.add(StmtContextUtils.parseNodeIdentifier(ctx, keyToken));
        tokens++;
    }

    // Throws NPE on nulls, retains first inserted value, cannot be modified
    final ImmutableSet<QName> ret = builder.build();
    SourceException.throwIf(ret.size() != tokens, ctx.getStatementSourceReference(),
            "Key argument '%s' contains duplicates", value);
    return ret;
}
 
源代码19 项目: ldp4j   文件: JPAResource.java
/**
 * {@inheritDoc}
 */
@Override
public Set<ConstraintReportId> constraintReports() {
	Set<String> currentFailures=null;
	synchronized(this) {
		currentFailures=ImmutableSet.copyOf(this.failures);
	}
	Builder<ConstraintReportId> builder=ImmutableSet.builder();
	for(String failure:currentFailures) {
		builder.add(ConstraintReportId.create(this.id,failure));
	}
	return builder.build();
}
 
源代码20 项目: ldp4j   文件: ImmutableNegotiationResult.java
private static <T> void addEntityIfPresent(Builder<T> builder, T entity) {
	if(entity!=null) {
		builder.add(entity);
	}
}