com.google.common.collect.ImmutableSet.Builder Java Examples
The following examples show how to use
com.google.common.collect.ImmutableSet.Builder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GssResourceGenerator.java From gss.gwt with Apache License 2.0 | 6 votes |
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(); }
Example #2
Source File: PacketAddOrUpdateTrain.java From Signals with GNU General Public License v3.0 | 6 votes |
@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(); }
Example #3
Source File: ZooKeeperEndpointGroupTest.java From armeria with Apache License 2.0 | 6 votes |
@Test void legacyDiscoverySpec() throws Throwable { final List<Endpoint> sampleEndpoints = ZooKeeperTestUtil.sampleEndpoints(3); setLegacySpecNodeChildren(sampleEndpoints); final ZooKeeperEndpointGroup endpointGroup = endpointGroup(ZooKeeperDiscoverySpec.legacy()); await().untilAsserted(() -> assertThat(endpointGroup.endpoints()).hasSameElementsAs(sampleEndpoints)); // Add two more nodes. final List<Endpoint> extraEndpoints = ZooKeeperTestUtil.sampleEndpoints(2); setLegacySpecNodeChildren(extraEndpoints); // Construct the final expected node list. final Builder<Endpoint> builder = ImmutableSet.builder(); builder.addAll(sampleEndpoints).addAll(extraEndpoints); try (CloseableZooKeeper zk = zkInstance.connection()) { zk.sync(Z_NODE, (rc, path, ctx) -> {}, null); } final Set<Endpoint> expected = builder.build(); await().untilAsserted(() -> assertThat(endpointGroup.endpoints()).hasSameElementsAs(expected)); disconnectZk(endpointGroup); }
Example #4
Source File: ZooKeeperEndpointGroupTest.java From armeria with Apache License 2.0 | 6 votes |
@Test void curatorDiscovery() throws Throwable { final List<Endpoint> sampleEndpoints = ZooKeeperTestUtil.sampleEndpoints(3); setCuratorXNodeChildren(sampleEndpoints, 0); final ZooKeeperDiscoverySpec spec = ZooKeeperDiscoverySpec.builderForCurator(CURATOR_X_SERVICE_NAME) .build(); final ZooKeeperEndpointGroup endpointGroup = endpointGroup(spec); await().untilAsserted(() -> assertThat(endpointGroup.endpoints()).hasSameElementsAs(sampleEndpoints)); // Add two more nodes. final List<Endpoint> extraEndpoints = ZooKeeperTestUtil.sampleEndpoints(2); setCuratorXNodeChildren(extraEndpoints, 3); // Construct the final expected node list. final Builder<Endpoint> builder = ImmutableSet.builder(); builder.addAll(sampleEndpoints).addAll(extraEndpoints); try (CloseableZooKeeper zk = zkInstance.connection()) { zk.sync(Z_NODE, (rc, path, ctx) -> {}, null); } final Set<Endpoint> expected = builder.build(); await().untilAsserted(() -> assertThat(endpointGroup.endpoints()).hasSameElementsAs(expected)); disconnectZk(endpointGroup); }
Example #5
Source File: StandardMessenger.java From Kettle with GNU General Public License v3.0 | 6 votes |
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(); } } }
Example #6
Source File: GetAnnotationCommandParser.java From james-project with Apache License 2.0 | 6 votes |
private void consumeOptionsAndKeys(ImapRequestLineReader requestReader, GetAnnotationRequest.Builder builder) throws DecodingException { while (requestReader.nextNonSpaceChar() == '(') { requestReader.consumeChar('('); switch (requestReader.nextChar()) { case 'M': consumeMaxsizeOpt(requestReader, builder); break; case 'D': consumeDepthOpt(requestReader, builder); break; default: consumeKeys(requestReader, builder); break; } } }
Example #7
Source File: SupportedOptions.java From Mixin with MIT License | 6 votes |
/** * 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(); }
Example #8
Source File: FibImpl.java From batfish with Apache License 2.0 | 6 votes |
/** * Attempt to resolve a RIB route down to an interface route. * * @param rib {@link GenericRib} for which to do the resolution. * @param route {@link AbstractRoute} with a next hop IP to be resolved. * @return A map (interface name -> last hop IP -> last taken route) for * @throws BatfishException if resolution depth is exceeded (high likelihood of a routing loop) OR * an invalid route in the RIB has been encountered. */ @VisibleForTesting Set<FibEntry> resolveRoute( GenericRib<? extends AbstractRouteDecorator> rib, AbstractRoute route) { ResolutionTreeNode resolutionRoot = ResolutionTreeNode.root(route); buildResolutionTree( rib, route, Route.UNSET_ROUTE_NEXT_HOP_IP, new HashSet<>(), 0, Prefix.MAX_PREFIX_LENGTH, null, resolutionRoot); Builder<FibEntry> collector = ImmutableSet.builder(); collectEntries(resolutionRoot, new Stack<>(), collector); return collector.build(); }
Example #9
Source File: FibImpl.java From batfish with Apache License 2.0 | 6 votes |
private void collectEntries( ResolutionTreeNode node, Stack<AbstractRoute> stack, ImmutableCollection.Builder<FibEntry> entriesBuilder) { if (node.getChildren().isEmpty() && node.getFinalNextHopIp() != null) { String nextHopInterface = node.getRoute().getNextHopInterface(); String nextVrf = getNextVrf(node.getRoute()); FibAction fibAction = nextVrf != null ? new FibNextVrf(nextVrf) : nextHopInterface.equals(Interface.NULL_INTERFACE_NAME) ? FibNullRoute.INSTANCE : new FibForward(node.getFinalNextHopIp(), nextHopInterface); entriesBuilder.add(new FibEntry(fibAction, ImmutableList.copyOf(stack))); return; } stack.push(node.getRoute()); for (ResolutionTreeNode child : node.getChildren()) { collectEntries(child, stack, entriesBuilder); } stack.pop(); }
Example #10
Source File: CumulusNcluConfiguration.java From batfish with Apache License 2.0 | 6 votes |
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); }
Example #11
Source File: EvpnL3VniPropertiesAnswerer.java From batfish with Apache License 2.0 | 6 votes |
/** * Gets properties of EVPN Layer 3 VNIs. * * @param nodes the set of nodes to consider * @param nc all network configurations * @param columns a map from column name to {@link ColumnMetadata} * @return A multiset of {@link Row}s where each row corresponds to a node and columns correspond * to property values. */ @Nonnull public static Set<Row> getRows( Set<String> nodes, NetworkConfigurations nc, Map<String, ColumnMetadata> columns) { Builder<Row> rows = ImmutableSet.builder(); for (String nodeName : nodes) { nc.get(nodeName).map(Configuration::getVrfs).orElse(ImmutableMap.of()).values().stream() .map(Vrf::getBgpProcess) .filter(Objects::nonNull) .flatMap(BgpProcess::allPeerConfigsStream) .map(BgpPeerConfig::getEvpnAddressFamily) .filter(Objects::nonNull) .flatMap(af -> af.getL3VNIs().stream()) .distinct() // Get rid of duplication across BGP peers (due to the VI model hierarchy) .map(c -> generateRow(c, nodeName, columns)) .forEach(rows::add); } return rows.build(); }
Example #12
Source File: StandardMessenger.java From Kettle with GNU General Public License v3.0 | 6 votes |
public Set<String> getIncomingChannels(Plugin plugin) { if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } synchronized (incomingLock) { Set<PluginMessageListenerRegistration> registrations = incomingByPlugin.get(plugin); if (registrations != null) { Builder<String> builder = ImmutableSet.builder(); for (PluginMessageListenerRegistration registration : registrations) { builder.add(registration.getChannel()); } return builder.build(); } else { return ImmutableSet.of(); } } }
Example #13
Source File: SwitchedVlanPropertiesAnswerer.java From batfish with Apache License 2.0 | 6 votes |
@VisibleForTesting static void computeNodeVlanProperties( SpecifierContext ctxt, Configuration c, InterfaceSpecifier interfacesSpecifier, boolean excludeShutInterfaces, IntegerSpace vlans, Map<Integer, ImmutableSet.Builder<NodeInterfacePair>> switchedVlanInterfaces, ImmutableMap.Builder<Integer, Integer> vlanVnisBuilder) { addVlanVnis(c, vlans, switchedVlanInterfaces, vlanVnisBuilder); Set<NodeInterfacePair> specifiedInterfaces = interfacesSpecifier.resolve(ImmutableSet.of(c.getHostname()), ctxt); for (Interface iface : c.getAllInterfaces().values()) { tryAddInterfaceToVlans( specifiedInterfaces, excludeShutInterfaces, vlans, switchedVlanInterfaces, iface); } }
Example #14
Source File: SwitchedVlanPropertiesAnswerer.java From batfish with Apache License 2.0 | 6 votes |
/** * Gets properties of switched vlans. * * @param ctxt context in which to apply {@code interfacesSpecifier} * @param configurations configuration to use in extractions * @param nodes the set of nodes to consider * @param interfaceSpecifier Specifies which interfaces to consider * @param columns a map from column name to {@link ColumnMetadata} * @return A multiset of {@link Row}s where each row corresponds to a node/vlan pair and columns * correspond to property values. */ public static Multiset<Row> getProperties( SpecifierContext ctxt, Map<String, Configuration> configurations, Set<String> nodes, InterfaceSpecifier interfaceSpecifier, boolean excludeShutInterfaces, IntegerSpace vlans, Map<String, ColumnMetadata> columns) { Multiset<Row> rows = HashMultiset.create(); for (String node : nodes) { Map<Integer, ImmutableSet.Builder<NodeInterfacePair>> switchedVlanInterfaces = new HashMap<>(); ImmutableMap.Builder<Integer, Integer> vlanVnisBuilder = ImmutableMap.builder(); computeNodeVlanProperties( ctxt, configurations.get(node), interfaceSpecifier, excludeShutInterfaces, vlans, switchedVlanInterfaces, vlanVnisBuilder); populateNodeRows(node, switchedVlanInterfaces, vlanVnisBuilder, columns, rows); } return rows; }
Example #15
Source File: KeyStatementSupport.java From yangtools with Eclipse Public License 1.0 | 6 votes |
@Override public Set<QName> adaptArgumentValue(final StmtContext<Set<QName>, KeyStatement, KeyEffectiveStatement> ctx, final QNameModule targetModule) { final Builder<QName> builder = ImmutableSet.builder(); boolean replaced = false; for (final QName qname : ctx.coerceStatementArgument()) { if (!targetModule.equals(qname.getModule())) { final QName newQname = qname.bindTo(targetModule).intern(); builder.add(newQname); replaced = true; } else { builder.add(qname); } } // This makes sure we reuse the collection when a grouping is // instantiated in the same module return replaced ? builder.build() : ctx.getStatementArgument(); }
Example #16
Source File: CumulusNcluConfiguration.java From batfish with Apache License 2.0 | 6 votes |
private org.batfish.datamodel.Interface toInterface(Vlan vlan) { org.batfish.datamodel.Interface newIface = org.batfish.datamodel.Interface.builder() .setName(vlan.getName()) .setOwner(_c) .setType(InterfaceType.VLAN) .build(); newIface.setActive(true); newIface.setVlan(vlan.getVlanId()); // Interface addreses if (!vlan.getAddresses().isEmpty()) { newIface.setAddress(vlan.getAddresses().get(0)); } ImmutableSet.Builder<InterfaceAddress> allAddresses = ImmutableSet.builder(); allAddresses.addAll(vlan.getAddresses()); vlan.getAddressVirtuals().values().forEach(allAddresses::addAll); newIface.setAllAddresses(allAddresses.build()); newIface.setDescription(vlan.getAlias()); return newIface; }
Example #17
Source File: ImmutableNegotiationResult.java From ldp4j with Apache License 2.0 | 6 votes |
ImmutableNegotiationResult(final ImmutableVariant variant, ImmutableQuality quality, final ImmutableVariant errorVariant, ImmutableAlternatives alternatives) { checkArgument( (variant==null && quality==null) || (variant!=null && quality!=null), "Variant and quality must be simultaneously defined or not (%s <--> %s)",variant,quality); checkNotNull(errorVariant,"Error variant cannot be null"); checkNotNull(alternatives,"Alternatives cannot be null"); this.variant=variant; this.quality=quality; this.errorVariant=errorVariant; this.alternatives=alternatives; Builder<MediaType> mtBuilder=ImmutableSet.<MediaType>builder(); Builder<CharacterEncoding> ceBuilder=ImmutableSet.<CharacterEncoding>builder(); Builder<Language> lBuilder=ImmutableSet.<Language>builder(); for(Alternative alternative:alternatives) { addEntityIfPresent(mtBuilder,alternative.type()); addEntityIfPresent(ceBuilder,alternative.charset()); addEntityIfPresent(lBuilder,alternative.language()); } this.mediaTypes=mtBuilder.build(); this.characterEncodings=ceBuilder.build(); this.languages=lBuilder.build(); }
Example #18
Source File: SwitchedVlanPropertiesAnswerer.java From batfish with Apache License 2.0 | 6 votes |
private static void addVlanVnis( Configuration c, IntegerSpace vlans, Map<Integer, ImmutableSet.Builder<NodeInterfacePair>> switchedVlanInterfaces, ImmutableMap.Builder<Integer, Integer> vlanVnisBuilder) { c.getVrfs() .values() .forEach( vrf -> vrf.getLayer2Vnis() .values() .forEach( vniSettings -> tryAddVlanVni( vniSettings, vlans, vlanVnisBuilder, switchedVlanInterfaces))); }
Example #19
Source File: AbstractReport.java From buck with Apache License 2.0 | 6 votes |
/** * It returns a list of trace files that corresponds to builds while respecting the maximum size * of the final zip file. * * @param entries the highlighted builds * @return a set of paths that points to the corresponding traces. */ private ImmutableSet<Path> getTracePathsOfBuilds(ImmutableSet<BuildLogEntry> entries) { ImmutableSet.Builder<Path> tracePaths = new ImmutableSet.Builder<>(); long reportSizeBytes = 0; for (BuildLogEntry entry : entries) { reportSizeBytes += entry.getSize(); if (entry.getTraceFile().isPresent()) { try { Path traceFile = filesystem.getPathForRelativeExistingPath(entry.getTraceFile().get()); long traceFileSizeBytes = Files.size(traceFile); if (doctorConfig.getReportMaxSizeBytes().isPresent()) { if (reportSizeBytes + traceFileSizeBytes < doctorConfig.getReportMaxSizeBytes().get()) { tracePaths.add(entry.getTraceFile().get()); reportSizeBytes += traceFileSizeBytes; } } else { tracePaths.add(entry.getTraceFile().get()); reportSizeBytes += traceFileSizeBytes; } } catch (IOException e) { LOG.info("Trace path %s wasn't valid, skipping it.", entry.getTraceFile().get()); } } } return tracePaths.build(); }
Example #20
Source File: ReflectiveDaoAdapter.java From microorm with Apache License 2.0 | 6 votes |
ReflectiveDaoAdapter(Class<T> klass, ImmutableList<FieldAdapter> fieldAdapters, ImmutableList<EmbeddedFieldInitializer> fieldInitializers) { mClassFactory = ClassFactory.get(klass); mFieldAdapters = fieldAdapters; mFieldInitializers = fieldInitializers; ImmutableList.Builder<String> projectionBuilder = ImmutableList.builder(); ImmutableList.Builder<String> writableColumnsBuilder = ImmutableList.builder(); for (FieldAdapter fieldAdapter : fieldAdapters) { projectionBuilder.add(fieldAdapter.getColumnNames()); writableColumnsBuilder.add(fieldAdapter.getWritableColumnNames()); } mProjection = array(projectionBuilder.build()); mWritableColumns = array(writableColumnsBuilder.build()); mWritableDuplicates = findDuplicates(mWritableColumns); }
Example #21
Source File: ReflectiveDaoAdapter.java From microorm with Apache License 2.0 | 5 votes |
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(); }
Example #22
Source File: CraftEnderDragon.java From Kettle with GNU General Public License v3.0 | 5 votes |
public Set<ComplexEntityPart> getParts() { Builder<ComplexEntityPart> builder = ImmutableSet.builder(); for (MultiPartEntityPart part : getHandle().dragonPartArray) { builder.add((ComplexEntityPart) part.getBukkitEntity()); } return builder.build(); }
Example #23
Source File: LinkageMonitor.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
/** * Returns a copy of {@code bom} replacing its managed dependencies that have locally-installed * snapshot versions. */ @VisibleForTesting static Bom copyWithSnapshot( RepositorySystem repositorySystem, RepositorySystemSession session, Bom bom, Map<String, String> localArtifacts) throws ModelBuildingException, ArtifactResolutionException { ImmutableList.Builder<Artifact> managedDependencies = ImmutableList.builder(); Model model = buildModelWithSnapshotBom(repositorySystem, session, bom.getCoordinates(), localArtifacts); ArtifactTypeRegistry registry = session.getArtifactTypeRegistry(); ImmutableList<Artifact> newManagedDependencies = model.getDependencyManagement().getDependencies().stream() .map(dependency -> RepositoryUtils.toDependency(dependency, registry)) .map(Dependency::getArtifact) .collect(toImmutableList()); for (Artifact managedDependency : newManagedDependencies) { if (Bom.shouldSkipBomMember(managedDependency)) { continue; } String version = localArtifacts.getOrDefault( managedDependency.getGroupId() + ":" + managedDependency.getArtifactId(), managedDependency.getVersion()); managedDependencies.add(managedDependency.setVersion(version)); } // "-SNAPSHOT" suffix for coordinate to distinguish easily. return new Bom(bom.getCoordinates() + "-SNAPSHOT", managedDependencies.build()); }
Example #24
Source File: KeyStatementSupport.java From yangtools with Eclipse Public License 1.0 | 5 votes |
@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; }
Example #25
Source File: BitsSerializationTest.java From yangtools with Eclipse Public License 1.0 | 5 votes |
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; }
Example #26
Source File: CodecsImpl.java From bgpcep with Eclipse Public License 1.0 | 5 votes |
public CodecsImpl(final RIBSupport<?, ?, ?, ?> ribSupport) { this.ribSupport = requireNonNull(ribSupport); final Builder<Class<? extends BindingObject>> acb = ImmutableSet.builder(); acb.addAll(ATTRIBUTE_CACHEABLES); acb.addAll(this.ribSupport.cacheableAttributeObjects()); this.cacheableAttributes = acb.build(); }
Example #27
Source File: SymbolProto.java From gama with GNU General Public License v3.0 | 5 votes |
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; } }
Example #28
Source File: Directories.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public TrueFilesSizeVisitor() { super(); Builder<String> builder = ImmutableSet.builder(); for (File file: sstableLister().listFiles()) builder.add(file.getName()); alive = builder.build(); }
Example #29
Source File: AbstractOffsetMap.java From bgpcep with Eclipse Public License 1.0 | 5 votes |
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()); }
Example #30
Source File: SwitchedVlanPropertiesAnswerer.java From batfish with Apache License 2.0 | 5 votes |
@VisibleForTesting static void tryAddVlanVni( Layer2Vni vniSettings, IntegerSpace vlans, ImmutableMap.Builder<Integer, Integer> vlanVnisBuilder, Map<Integer, ImmutableSet.Builder<NodeInterfacePair>> switchedVlanInterfaces) { if (vlans.contains(vniSettings.getVlan())) { int vlan = vniSettings.getVlan(); vlanVnisBuilder.put(vlan, vniSettings.getVni()); switchedVlanInterfaces.computeIfAbsent(vlan, v -> ImmutableSet.builder()); } }