List of usage examples for com.google.common.collect ImmutableSet.Builder add
boolean add(E e);
From source file:com.squareup.auto.value.redacted.AutoValueRedactedExtension.java
private static ImmutableSet<String> getAnnotations(ExecutableElement element) { ImmutableSet.Builder<String> builder = ImmutableSet.builder(); List<? extends AnnotationMirror> annotations = element.getAnnotationMirrors(); for (AnnotationMirror annotation : annotations) { builder.add(annotation.getAnnotationType().asElement().getSimpleName().toString()); }/* w w w. j a v a2 s .com*/ return builder.build(); }
From source file:com.facebook.presto.raptor.storage.organization.ShardOrganizationManager.java
private static Set<OrganizationSet> getOverlappingOrganizationSets(Table tableInfo, Collection<ShardIndexInfo> shards) { if (shards.size() <= 1) { return ImmutableSet.of(); }//from ww w. j a va 2 s .c om // Sort by low marker for the range List<ShardIndexInfo> sortedShards = shards.stream().sorted((o1, o2) -> { ShardRange sortRange1 = o1.getSortRange().get(); ShardRange sortRange2 = o2.getSortRange().get(); return ComparisonChain.start().compare(sortRange1.getMinTuple(), sortRange2.getMinTuple()) .compare(sortRange2.getMaxTuple(), sortRange1.getMaxTuple()).result(); }).collect(toList()); Set<OrganizationSet> organizationSets = new HashSet<>(); ImmutableSet.Builder<ShardIndexInfo> builder = ImmutableSet.builder(); builder.add(sortedShards.get(0)); int previousRange = 0; int nextRange = previousRange + 1; while (nextRange < sortedShards.size()) { ShardRange sortRange1 = sortedShards.get(previousRange).getSortRange().get(); ShardRange sortRange2 = sortedShards.get(nextRange).getSortRange().get(); if (sortRange1.overlaps(sortRange2) && !sortRange1.adjacent(sortRange2)) { builder.add(sortedShards.get(nextRange)); if (!sortRange1.encloses(sortRange2)) { previousRange = nextRange; } } else { Set<ShardIndexInfo> indexInfos = builder.build(); if (indexInfos.size() > 1) { organizationSets.add(createOrganizationSet(tableInfo.getTableId(), indexInfos)); } builder = ImmutableSet.builder(); previousRange = nextRange; builder.add(sortedShards.get(previousRange)); } nextRange++; } Set<ShardIndexInfo> indexInfos = builder.build(); if (indexInfos.size() > 1) { organizationSets.add(createOrganizationSet(tableInfo.getTableId(), indexInfos)); } return organizationSets; }
From source file:google.registry.flows.FlowReporter.java
/** * Returns the set of unique results of {@link #extractTld} applied to each given domain name, * excluding any absent results (i.e. cases where no TLD was detected). *///from w ww. j a va 2 s.c o m private static final ImmutableSet<String> extractTlds(Iterable<String> domainNames) { ImmutableSet.Builder<String> set = new ImmutableSet.Builder<>(); for (String domainName : domainNames) { Optional<String> extractedTld = extractTld(domainName); if (extractedTld.isPresent()) { set.add(extractedTld.get()); } } return set.build(); }
From source file:io.github.mywarp.mywarp.bukkit.util.material.ConfigurableMaterialInfo.java
private static ImmutableSet<Material> fromConfig(String path, ConfigurationSection config) { ImmutableSet.Builder<Material> builder = ImmutableSet.builder(); config.getStringList(path).forEach(name -> { @Nullable//from w w w. j a v a 2 s. c o m Material material = Material.getMaterial(name); if (material != null) { builder.add(material); } else { log.debug("'{}' does not match any known Material.", name); } }); return builder.build(); }
From source file:google.registry.testing.FullFieldsTestEntityHelper.java
public static DomainResource makeDomainResource(String domain, @Nullable ContactResource registrant, @Nullable ContactResource admin, @Nullable ContactResource tech, @Nullable HostResource ns1, @Nullable HostResource ns2, Registrar registrar) { DomainResource.Builder builder = new DomainResource.Builder() .setFullyQualifiedDomainName(Idn.toASCII(domain)) .setRepoId(generateNewDomainRoid(getTldFromDomainName(Idn.toASCII(domain)))) .setLastEppUpdateTime(DateTime.parse("2009-05-29T20:13:00Z")) .setCreationTimeForTest(DateTime.parse("2000-10-08T00:45:00Z")) .setRegistrationExpirationTime(DateTime.parse("2110-10-08T00:44:59Z")) .setCurrentSponsorClientId(registrar.getClientId()) .setStatusValues(// ww w . ja va 2 s . c o m ImmutableSet.of(StatusValue.CLIENT_DELETE_PROHIBITED, StatusValue.CLIENT_RENEW_PROHIBITED, StatusValue.CLIENT_TRANSFER_PROHIBITED, StatusValue.SERVER_UPDATE_PROHIBITED)) .setDsData(ImmutableSet.of(new DelegationSignerData())); if (registrant != null) { builder.setRegistrant(Key.create(registrant)); } if ((admin != null) || (tech != null)) { ImmutableSet.Builder<DesignatedContact> contactsBuilder = new ImmutableSet.Builder<>(); if (admin != null) { contactsBuilder.add(DesignatedContact.create(DesignatedContact.Type.ADMIN, Key.create(admin))); } if (tech != null) { contactsBuilder.add(DesignatedContact.create(DesignatedContact.Type.TECH, Key.create(tech))); } builder.setContacts(contactsBuilder.build()); } if ((ns1 != null) || (ns2 != null)) { ImmutableSet.Builder<Key<HostResource>> nsBuilder = new ImmutableSet.Builder<>(); if (ns1 != null) { nsBuilder.add(Key.create(ns1)); } if (ns2 != null) { nsBuilder.add(Key.create(ns2)); } builder.setNameservers(nsBuilder.build()); } return builder.build(); }
From source file:com.textocat.textokit.commons.cas.FSUtils.java
public static Set<String> toSet(StringArrayFS fsArr) { if (fsArr == null) return ImmutableSet.of(); ImmutableSet.Builder<String> resultBuilder = ImmutableSet.builder(); for (int i = 0; i < fsArr.size(); i++) { resultBuilder.add(fsArr.get(i)); }/*from w ww. j a v a 2 s . c o m*/ return resultBuilder.build(); }
From source file:io.prestosql.sql.planner.optimizations.LocalProperties.java
public static <T> Set<T> extractLeadingConstants(List<? extends LocalProperty<T>> properties) { ImmutableSet.Builder<T> builder = ImmutableSet.builder(); PeekingIterator<? extends LocalProperty<T>> iterator = peekingIterator(properties.iterator()); while (iterator.hasNext() && iterator.peek() instanceof ConstantProperty) { builder.add(((ConstantProperty<T>) iterator.next()).getColumn()); }//from w w w . j a v a2 s . c o m return builder.build(); }
From source file:io.takari.swagger.ReflectionHelper.java
private static <T extends Annotation> void addEffectiveClassAnnotations(Class<?> type, Class<T> annotation, ImmutableSet.Builder<T> builder) { if (type.isAnnotationPresent(annotation)) { builder.add(type.getAnnotation(annotation)); return;//from www . ja va 2 s . c o m } if (type.getSuperclass() != null) { addEffectiveClassAnnotations(type.getSuperclass(), annotation, builder); } for (Class<?> anInterface : type.getInterfaces()) { addEffectiveClassAnnotations(anInterface, annotation, builder); } }
From source file:com.b2international.snowowl.snomed.datastore.index.interest.SearchProfile.java
private static Iterable<SearchProfileRule> getPreferencesRules(final Preferences profileNode) throws BackingStoreException { checkNotNull(profileNode, "profileNode"); final ImmutableSet.Builder<SearchProfileRule> preferencesRulesBuilder = ImmutableSet.builder(); for (final String childName : profileNode.childrenNames()) { preferencesRulesBuilder.add(new SearchProfileRule(profileNode.node(childName))); }// w w w . j a v a 2 s. c om return preferencesRulesBuilder.build(); }
From source file:org.sosy_lab.cpachecker.cpa.invariants.InvariantsPrecision.java
private static ImmutableSet<CFAEdge> asImmutableRelevantEdges(Set<CFAEdge> pRelevantEdges) { if (pRelevantEdges == null) { return null; }//w ww.j ava2 s . co m ImmutableSet.Builder<CFAEdge> builder = ImmutableSet.builder(); Queue<CFAEdge> waitlist = new ArrayDeque<>(pRelevantEdges); while (!waitlist.isEmpty()) { CFAEdge relevantEdge = waitlist.poll(); builder.add(relevantEdge); if (relevantEdge.getEdgeType() == CFAEdgeType.MultiEdge) { builder.addAll(((MultiEdge) relevantEdge)); } } return builder.build(); }