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:com.spotify.heroic.aggregation.Collapse.java

@Override
public CollapseInstance apply(final AggregationContext context) {
    final AggregationInstance instance = each.orElse(Empty.INSTANCE).apply(context);

    final Optional<List<String>> of = this.of.map(o -> {
        final ImmutableSet.Builder<String> b = ImmutableSet.builder();
        b.addAll(o).addAll(context.requiredTags());
        return ImmutableList.copyOf(b.build());
    });/*from w  ww .ja  v  a  2s. c o m*/

    return new CollapseInstance(of, instance);
}

From source file:io.prestosql.sql.planner.SymbolsExtractor.java

public static Set<Symbol> extractUnique(PlanNode node, Lookup lookup) {
    ImmutableSet.Builder<Symbol> uniqueSymbols = ImmutableSet.builder();
    extractExpressions(node, lookup).forEach(expression -> uniqueSymbols.addAll(extractUnique(expression)));

    return uniqueSymbols.build();
}

From source file:org.caleydo.view.domino.internal.tourguide.ui.EntityTypeSelector.java

/**
 * @return/*from   w  w  w.ja  v a 2 s .  co  m*/
 */
public static Set<IDCategory> findAllUsedIDCategories() {
    ImmutableSet.Builder<IDCategory> b = ImmutableSortedSet.orderedBy(new Comparator<IDCategory>() {
        @Override
        public int compare(IDCategory o1, IDCategory o2) {
            return String.CASE_INSENSITIVE_ORDER.compare(o1.getCategoryName(), o2.getCategoryName());
        }
    });
    IDataSupportDefinition inhomogenous = DataSupportDefinitions.inhomogenousTables;
    for (ATableBasedDataDomain d : DataDomainManager.get().getDataDomainsByType(ATableBasedDataDomain.class)) {
        b.add(d.getRecordIDCategory());
        if (!inhomogenous.apply(d)) // just in case of uniform tables
            b.add(d.getDimensionIDCategory());
    }
    return b.build();
}

From source file:com.facebook.buck.rules.modern.impl.ModernBuildableSupport.java

/** Derives an ArtifactVerifier from the @AddToRuleKey annotated fields. */
public static RecordArtifactVerifier getDerivedArtifactVerifier(BuildTarget target,
        ProjectFilesystem filesystem, AddsToRuleKey buildable, BuildableContext buildableContext) {
    ImmutableSet.Builder<Path> allowedPathsBuilder = ImmutableSet.builder();
    ModernBuildRule.recordOutputs(allowedPathsBuilder::add, newOutputPathResolver(target, filesystem),
            buildable);/*from  w w w .  java2s  .c  om*/
    return new RecordArtifactVerifier(allowedPathsBuilder.build(), buildableContext);
}

From source file:org.chalup.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);//from   w w  w . ja va2s . c o  m
        }
    }

    return result.build();
}

From source file:com.facebook.buck.util.MorePosixFilePermissions.java

/**
 * Convert a unix bit representation (e.g. 0644) into a set of posix file permissions.
 *//* w w w.  jav a 2 s .c  o m*/
public static ImmutableSet<PosixFilePermission> fromMode(long mode) {
    ImmutableSet.Builder<PosixFilePermission> permissions = ImmutableSet.builder();

    for (int index = 0; index < ORDERED_PERMISSIONS.size(); index++) {
        if ((mode & (1 << index)) != 0) {
            permissions.add(ORDERED_PERMISSIONS.get(index));
        }
    }

    return permissions.build();
}

From source file:org.gradle.api.internal.changedetection.state.IgnoringResourceHasher.java

public IgnoringResourceHasher(Set<String> ignores, ResourceHasher delegate) {
    this.delegate = delegate;
    this.ignores = ImmutableSet.copyOf(ignores);
    ImmutableSet.Builder<PathMatcher> builder = ImmutableSet.builder();
    for (String ignore : ignores) {
        PathMatcher matcher = PatternMatcherFactory.compile(true, ignore);
        builder.add(matcher);/*from   w  w w.  j av a  2  s .co  m*/
    }
    this.ignoreMatchers = builder.build();
}

From source file:org.apache.jackrabbit.oak.spi.security.privilege.ImmutablePrivilegeDefinition.java

public ImmutablePrivilegeDefinition(String name, boolean isAbstract, Iterable<String> declaredAggregateNames) {
    this.name = name;
    this.isAbstract = isAbstract;
    ImmutableSet.Builder<String> builder = ImmutableSet.builder();
    if (declaredAggregateNames != null) {
        builder.addAll(declaredAggregateNames);
    }//from  ww w  .  j a va 2s  . c  om
    this.declaredAggregateNames = builder.build();
}

From source file:de.se_rwth.langeditor.global.LanguageLocator.java

public LanguageLocator() {
    Builder<Language> builder = ImmutableSet.builder();

    IConfigurationElement[] configurationElements = Platform.getExtensionRegistry()
            .getConfigurationElementsFor(Constants.LANGUAGE_EXTENSION_POINT);

    for (IConfigurationElement configurationElement : configurationElements) {
        try {/*from   w ww. ja  v a  2s  . co  m*/
            Language language = (Language) configurationElement
                    .createExecutableExtension(Constants.LANGUAGE_EXTENSION_POINT_IMPLEMENTATION);
            builder.add(new ErrorCatchingLanguage(language));
        } catch (CoreException e) {
            throw new RuntimeException(e);
        }
    }
    languages = builder.build();
}

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

public ExtendsKeywordValidator(final JsonNode schema) {
    super("extends", NodeType.values());
    final JsonNode node = schema.get(keyword);
    final ImmutableSet.Builder<JsonNode> builder = new ImmutableSet.Builder<JsonNode>();

    /*/*from   w w  w.j av  a 2  s . c o m*/
     * Again, the fact that syntax validation has ensured our schema's
     * correctness helps greatly: the keyword value is either an object
     * or an array of objects.
     *
     * If this is an array, just cycle through its elements and stuff
     * them in our schema set. It should be noted that the draft DOES NOT
     * require that elements in the array must be unique,
     * but we swallow duplicates this way.
     */

    if (node.isObject())
        builder.add(node);
    else
        builder.addAll(node);

    schemas = builder.build();
}