Example usage for com.google.common.collect ImmutableSet.Builder add

List of usage examples for com.google.common.collect ImmutableSet.Builder add

Introduction

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

Prototype

boolean add(E e);

Source Link

Document

Adds the specified element to this set if it is not already present (optional operation).

Usage

From source file:org.apache.hadoop.hive.ql.optimizer.calcite.HiveCalciteUtil.java

public static ImmutableSet<Integer> shiftVColsSet(Set<Integer> hiveVCols, int shift) {
    ImmutableSet.Builder<Integer> bldr = ImmutableSet.<Integer>builder();

    for (Integer pos : hiveVCols) {
        bldr.add(shift + pos);
    }//from  w ww  .  j a  v  a2s . c  o  m

    return bldr.build();
}

From source file:com.google.devtools.build.lib.rules.objc.ObjcLibraryCcLinkParamsStore.java

@Override
protected void collect(CcLinkParams.Builder builder, boolean linkingStatically, boolean linkShared) {
    ObjcProvider objcProvider = common.getObjcProvider();

    ImmutableSet.Builder<LibraryToLink> libraries = new ImmutableSet.Builder<>();
    for (Artifact library : objcProvider.get(ObjcProvider.LIBRARY)) {
        libraries.add(LinkerInputs.opaqueLibraryToLink(library, ArtifactCategory.STATIC_LIBRARY,
                FileSystemUtils.removeExtension(library.getRootRelativePathString())));
    }/*  w  w w  . j  a  v  a  2s.c  o  m*/

    libraries.addAll(objcProvider.get(ObjcProvider.CC_LIBRARY));

    builder.addLibraries(libraries.build());
}

From source file:com.facebook.presto.hive.metastore.CachingHiveMetastore.java

private static Set<HivePrivilege> toGrants(List<PrivilegeGrantInfo> userGrants) {
    if (userGrants == null) {
        return ImmutableSet.of();
    }/*from   w w  w  .  j  a  va2s  .co  m*/

    ImmutableSet.Builder<HivePrivilege> privileges = ImmutableSet.builder();
    for (PrivilegeGrantInfo userGrant : userGrants) {
        privileges.addAll(parsePrivilege(userGrant));
        if (userGrant.isGrantOption()) {
            privileges.add(HivePrivilege.GRANT);
        }
    }
    return privileges.build();
}

From source file:com.netflix.genie.common.dto.ClusterCriteria.java

/**
 * Create a cluster criteria object with the included tags.
 *
 * @param tags The tags to add. Not null or empty and must have at least one non-empty tag.
 *///from www .j  a v a2 s.  c o m
@JsonCreator
public ClusterCriteria(@JsonProperty("tags") final Set<String> tags) {
    final ImmutableSet.Builder<String> builder = ImmutableSet.builder();
    tags.forEach(tag -> {
        if (StringUtils.isNotBlank(tag)) {
            builder.add(tag);
        }
    });
    this.tags = builder.build();
}

From source file:io.druid.server.lookup.cache.LookupNodeDiscovery.java

public Set<String> getAllTiers() {
    ImmutableSet.Builder<String> builder = new ImmutableSet.Builder<>();

    druidNodeDiscovery.getAllNodes().stream()
            .forEach(node -> builder
                    .add(((LookupNodeService) node.getServices().get(LookupNodeService.DISCOVERY_SERVICE_KEY))
                            .getLookupTier()));

    return builder.build();
}

From source file:org.lenskit.data.entities.BasicEntity.java

@Override
public Set<TypedName<?>> getTypedAttributeNames() {
    // TODO Make this more efficient
    ImmutableSet.Builder<TypedName<?>> bld = ImmutableSet.builder();
    for (Attribute<?> name : attributes.values()) {
        bld.add(name.getTypedName());
    }/*w  w w  . ja va 2 s . c o  m*/
    return bld.build();
}

From source file:com.google.template.soy.types.proto.AmbiguousFieldSet.java

AmbiguousFieldSet(String name, Set<ExtensionField> fields) {
    Preconditions.checkArgument(fields.size() > 1);

    this.name = name;
    this.extensions = ImmutableSet.copyOf(fields);

    ImmutableSet.Builder<String> builder = ImmutableSet.builder();
    for (ExtensionField field : fields) {
        builder.add(field.fieldDescriptor.getFullName());
    }/*from   w w  w.  j av  a  2 s.  c o  m*/
    this.fullFieldNames = builder.build();
}

From source file:io.motown.ocpp.websocketjson.response.handler.GetConfigurationResponseHandler.java

/**
 * Converts a {@code List} of {@code ConfigurationKey}s to a {@code Set} of {@code ConfigurationItem}s.
 *
 * @param configurationItemMap a {@code List} of {@code ConfigurationKey}s.
 * @return a {@code Set} of {@code ConfigurationItem}s.
 *///from  w ww. ja va 2s .c o  m
private Set<ConfigurationItem> toConfigurationItems(List<ConfigurationKey> configurationItemMap) {
    ImmutableSet.Builder<ConfigurationItem> configurationItemsBuilder = ImmutableSet.builder();

    for (ConfigurationKey key : configurationItemMap) {
        configurationItemsBuilder.add(new ConfigurationItem(key.getKey(), key.getValue()));
    }

    return configurationItemsBuilder.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 w w  .  j  av a2 s.c  o m
    this.assumeModifiedFiles = modifiedFilesBuilder.build();
}

From source file:org.androidtransfuse.util.matcher.InjectionSignatureMatcherBuilder.java

public InjectionSignatureMatcherBuilder byType(ASTType... type) {
    ImmutableSet.Builder<ASTType> builder = ImmutableSet.builder();
    if (type != null) {
        for (ASTType astType : type) {
            builder.add(astType);
        }//w  w  w  .ja  v a2s .  c  o m
    }
    return byType(builder.build());
}