Example usage for com.google.common.collect ImmutableSet builder

List of usage examples for com.google.common.collect ImmutableSet builder

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableSet builder.

Prototype

public static <E> Builder<E> builder() 

Source Link

Usage

From source file:org.apache.aurora.scheduler.filter.SchedulingFilterImpl.java

private static void maybeAddVeto(ImmutableSet.Builder<Veto> vetoes, ResourceType resourceType, double available,
        double requested) {

    double tooLarge = requested - available;
    if (tooLarge > 0) {
        vetoes.add(Veto.insufficientResources(resourceType.getAuroraName(),
                scale(tooLarge, resourceType.getScalingRange())));
    }//from   www . j  a va 2s .  c om
}

From source file:org.jclouds.elasticstack.functions.MapToDevices.java

public Map<String, ? extends Device> apply(Map<String, String> from) {
    Builder<Device> devices = ImmutableSet.builder();
    addIDEDevices(from, devices);//from   w ww  .  jav  a 2  s.c  o  m
    addSCSIDevices(from, devices);
    addBlockDevices(from, devices);

    return Maps.uniqueIndex(devices.build(), deviceToId);
}

From source file:org.codice.ddf.admin.common.fields.common.PortField.java

@Override
public Set<String> getErrorCodes() {
    return new ImmutableSet.Builder<String>().addAll(super.getErrorCodes())
            .add(DefaultMessages.INVALID_PORT_RANGE).build();
}

From source file:org.eel.kitchen.jsonschema.keyword.AbstractTypeKeywordValidator.java

protected AbstractTypeKeywordValidator(final String keyword, final JsonNode schema) {
    super(keyword, NodeType.values());
    final JsonNode node = schema.get(keyword);

    if (node.isTextual()) {
        addSimpleType(node.textValue());
        schemas = Collections.emptySet();
        return;/*from w  w  w.j  a  v a  2 s. c  o m*/
    }

    final ImmutableSet.Builder<JsonNode> builder = new ImmutableSet.Builder<JsonNode>();

    for (final JsonNode element : node)
        if (element.isTextual())
            addSimpleType(element.textValue());
        else
            builder.add(element);

    schemas = builder.build();
}

From source file:org.apache.calcite.rel.core.CorrelationId.java

/** Converts a set of correlation ids to a set of names. */
public static ImmutableSet<CorrelationId> setOf(Set<String> set) {
    if (set.isEmpty()) {
        return ImmutableSet.of();
    }/*from   ww w  .j  av  a 2 s . co m*/
    final ImmutableSet.Builder<CorrelationId> builder = ImmutableSet.builder();
    for (String s : set) {
        builder.add(new CorrelationId(s));
    }
    return builder.build();
}

From source file:com.tngtech.archunit.core.importer.Locations.java

/**
 * All {@link Location locations} in the classpath that match the supplied package.
 *
 * @param pkg the package to look for within the classpath
 * @return {@link Location Locations} of all paths that match the supplied package
 *//* w w w.  j a v  a2 s.c  om*/
@PublicAPI(usage = ACCESS)
public static Set<Location> ofPackage(String pkg) {
    ImmutableSet.Builder<Location> result = ImmutableSet.builder();
    for (Location location : getLocationsOf(asResourceName(pkg))) {
        result.add(location);
    }
    return result.build();
}

From source file:com.facebook.buck.hashing.FilePathHashLoader.java

public FilePathHashLoader(final Path defaultCellRoot, ImmutableSet<Path> assumeModifiedFiles)
        throws IOException {
    this.defaultCellRoot = defaultCellRoot;
    ImmutableSet.Builder<Path> modifiedFilesBuilder = ImmutableSet.builder();
    for (Path path : assumeModifiedFiles) {
        modifiedFilesBuilder.add(defaultCellRoot.resolve(path).toRealPath());
    }//from  w ww . ja va  2 s  .  c  o m
    this.assumeModifiedFiles = modifiedFilesBuilder.build();
}

From source file:zipkin.storage.cassandra.CompositeIndexer.java

ImmutableSet<ListenableFuture<?>> index(List<Span> spans) {
    ImmutableSet.Builder<ListenableFuture<?>> result = ImmutableSet.builder();
    for (Indexer optimizer : indexers) {
        result.addAll(optimizer.index(spans));
    }/*w  w  w .  j  av  a 2  s. c  om*/
    return result.build();
}

From source file:org.eclipse.sw360.datahandler.permissions.ProjectPermissions.java

protected ProjectPermissions(Project document, User user) {
    super(document, user);

    moderators = new ImmutableSet.Builder<String>().addAll(toSingletonSet(document.getCreatedBy()))
            .addAll(toSingletonSet(document.getProjectResponsible()))
            .addAll(nullToEmptySet(document.getModerators())).build();
    contributors = new ImmutableSet.Builder<String>().addAll(moderators)
            .addAll(nullToEmptySet(document.getContributors()))
            .addAll(toSingletonSet(document.getLeadArchitect())).build();
    attachmentContentIds = nullToEmptySet(document.getAttachments()).stream()
            .map(a -> a.getAttachmentContentId()).collect(Collectors.toSet());
}

From source file:org.onosproject.segmentrouting.config.XConnectConfig.java

/**
 * Returns all xconnect keys./* w  w  w  . j  av a 2  s  .  co  m*/
 *
 * @return all keys (device/vlan pairs)
 * @throws IllegalArgumentException if wrong format
 */
public Set<XConnectStoreKey> getXconnects() {
    ImmutableSet.Builder<XConnectStoreKey> builder = ImmutableSet.builder();
    object.fields().forEachRemaining(entry -> {
        DeviceId deviceId = DeviceId.deviceId(entry.getKey());
        builder.addAll(getXconnects(deviceId));
    });
    return builder.build();
}