List of usage examples for com.google.common.collect ImmutableSet builder
public static <E> Builder<E> builder()
From source file:com.facebook.buck.android.AndroidResourceDetails.java
/** * @param androidResources A sequence of {@code android_resource} rules, ordered such that * resources from rules that appear earlier in the list will take precedence over resources * from rules that appear later in the list in the event of the conflict. This matches the * order the directories should be passed to {@code aapt} to have the same precedence * resolution.//from w w w. j a v a 2 s. com */ @Beta public AndroidResourceDetails(ImmutableList<HasAndroidResourceDeps> androidResources) { ImmutableSet.Builder<Path> resDirectoryBuilder = ImmutableSet.builder(); ImmutableSet.Builder<String> rDotJavaPackageBuilder = ImmutableSet.builder(); ImmutableSet.Builder<Path> whitelistedStringDirsBuilder = ImmutableSet.builder(); for (HasAndroidResourceDeps androidResource : androidResources) { Path resDirectory = androidResource.getRes(); if (resDirectory != null) { resDirectoryBuilder.add(resDirectory); rDotJavaPackageBuilder.add(androidResource.getRDotJavaPackage()); if (androidResource.hasWhitelistedStrings()) { whitelistedStringDirsBuilder.add(resDirectory); } } } resDirectories = resDirectoryBuilder.build(); rDotJavaPackages = rDotJavaPackageBuilder.build(); whitelistedStringDirs = whitelistedStringDirsBuilder.build(); }
From source file:co.cask.cdap.internal.app.queue.AbstractQueueSpecificationGenerator.java
/** * Finds a equal or compatible schema connection between <code>source</code> and <code>target</code> * flowlet.// w ww . j a v a2s .com */ protected Set<QueueSpecification> generateQueueSpecification(Id.Application app, String flow, FlowletConnection connection, Map<String, Set<Schema>> inputSchemas, Map<String, Set<Schema>> outputSchemas) { ImmutableSet.Builder<QueueSpecification> builder = ImmutableSet.builder(); // Iterate through all the outputs and look for an input with compatible schema. // If no such input is found, look for one with ANY_INPUT. // If there is exact match of schema then we pick that over the compatible one. for (Map.Entry<String, Set<Schema>> entryOutput : outputSchemas.entrySet()) { String outputName = entryOutput.getKey(); Set<Schema> nameOutputSchemas = inputSchemas.get(outputName); ImmutablePair<Schema, Schema> schemas = (nameOutputSchemas == null) ? null : SchemaFinder.findSchema(entryOutput.getValue(), nameOutputSchemas); if (schemas == null) { // Try ANY_INPUT Set<Schema> anyInputSchemas = inputSchemas.get(FlowletDefinition.ANY_INPUT); if (anyInputSchemas != null) { schemas = SchemaFinder.findSchema(entryOutput.getValue(), anyInputSchemas); } } if (schemas == null) { continue; } if (connection.getSourceType() == FlowletConnection.Type.STREAM) { builder.add(createSpec(QueueName.fromStream(app.getNamespaceId(), outputName), schemas.getFirst(), schemas.getSecond())); } else { builder.add(createSpec(QueueName.fromFlowlet(app.getNamespaceId(), app.getId(), flow, connection.getSourceName(), outputName), schemas.getFirst(), schemas.getSecond())); } } return builder.build(); }
From source file:com.djd.fun.tachchapter.demo014swing.maze.models.Floor.java
/** * Create an instance of floor based on given floorPlan * * @param floorPlan has to be at least 1x1 size. */// w w w. j a v a2 s .co m public Floor(String[][] floorPlan) { checkNotNull(floorPlan); // TODO do floorPlan size validation if (floorPlan.length < 1 || floorPlan[0].length < 1) { throw new IllegalArgumentException("floor must be at least 1x1"); } this.numOfRows = floorPlan.length; this.numOfCols = floorPlan[0].length; ImmutableSet.Builder<Location> tokenLocationBuilder = ImmutableSet.builder(); ImmutableSet.Builder<Location> enemyLocationBuilder = ImmutableSet.builder(); ImmutableSet.Builder<Location> gemLocationBuilder = ImmutableSet.builder(); tiles = new Tile[floorPlan.length][floorPlan[0].length]; Location playerLocation = null; for (int row = 0; row < numOfRows; row++) { for (int col = 0; col < numOfCols; col++) { String letter = floorPlan[row][col]; if (Strings.isNullOrEmpty(letter)) { throw new IllegalArgumentException( String.format("Bad floorPlan on [%d][%d] is null", row, col)); } char tileType = letter.charAt(0); // identify player location if ('P' == tileType) { playerLocation = Location.of(row, col); } else if ('T' == tileType) { tokenLocationBuilder.add(Location.of(row, col)); } else if ('E' == tileType) { enemyLocationBuilder.add(Location.of(row, col)); } else if ('G' == tileType) { gemLocationBuilder.add(Location.of(row, col)); } tiles[row][col] = Tile.of(row, col, tileType); } } this.playerOriginalLocation = checkNotNull(playerLocation); this.enemyLocations = enemyLocationBuilder.build(); this.tokenLocations = tokenLocationBuilder.build(); this.gemLocations = gemLocationBuilder.build(); }
From source file:fr.inria.maestro.lga.clustering.impl.ClusterImpl.java
/** * Creates class of classification./*from ww w. j a v a2s.c om*/ * @param name - the name of class * @param entries - the entries of class * @param holder - the properties of class */ public ClusterImpl(final String name, final ImmutableList<IClusterEntry> entries, final IPropertiesHolder holder) { this.name = name; this.entries = entries; this.holder = holder; final Builder<String> builder = ImmutableSet.builder(); for (final IClusterEntry entry : entries) { builder.add(entry.getName()); } this.entryNames = builder.build(); }
From source file:com.facebook.buck.rules.TargetGroup.java
public TargetGroup withReplacedTargets(Map<BuildTarget, Iterable<BuildTarget>> replacements) { ImmutableSet.Builder<BuildTarget> newTargets = ImmutableSet.builder(); for (BuildTarget existingTarget : targets) { if (replacements.containsKey(existingTarget)) { newTargets.addAll(replacements.get(existingTarget)); } else {/*from w ww .j av a 2 s .c om*/ newTargets.add(existingTarget); } } return new TargetGroup(newTargets.build(), Optional.of(restrictOutboundVisibility), buildTarget); }
From source file:pw.swordfish.validation.DirectoryValidator.java
private ImmutableSet<ConstraintViolation<File>> getValidationsSet(File file) { ImmutableSet.Builder<ConstraintViolation<File>> constraintBuilder = ImmutableSet.builder(); Path path = file.toPath();//from ww w.jav a 2s . com if (!Files.exists(path)) { constraintBuilder.add(new DirectoryConstraintValidation(file, "Directory doesn't exist " + path.toString(), new IOException(path.toString()))); return constraintBuilder.build(); } if (!Files.isDirectory(path)) { constraintBuilder.add(new DirectoryConstraintValidation(file, "Not a directory " + path.toString(), new NotDirectoryException(path.toString()))); } if (!Files.isReadable(path)) { constraintBuilder.add(new DirectoryConstraintValidation(file, "Access denied " + path.toString(), new AccessDeniedException(path.toString()))); } return constraintBuilder.build(); }
From source file:com.google.devtools.build.lib.actions.CompositeRunfilesSupplier.java
@Override public Iterable<Artifact> getArtifacts() { ImmutableSet.Builder<Artifact> result = ImmutableSet.builder(); for (RunfilesSupplier supplier : suppliers) { result.addAll(supplier.getArtifacts()); }/*from w w w.ja va 2 s. c om*/ return result.build(); }
From source file:org.jclouds.vcloud.director.v1_5.compute.suppliers.VirtualHardwareConfigSupplier.java
@Inject public VirtualHardwareConfigSupplier( @Named(VCloudDirectorConstants.PROPERTY_VCLOUD_DIRECTOR_HARDWARE_MAX_CPU) int maxCpuFromProperties, @Named(VCloudDirectorConstants.PROPERTY_VCLOUD_DIRECTOR_HARDWARE_MIN_RAM) int minRamFromProperties, @Named(VCloudDirectorConstants.PROPERTY_VCLOUD_DIRECTOR_HARDWARE_MAX_RAM) int maxRamFromProperties, @Named(VCloudDirectorConstants.PROPERTY_VCLOUD_DIRECTOR_PREDEFINED_HARDWARE_PROFILES) String predefinedProfiles) { // Synthetic profiles ImmutableSet.Builder<Hardware> builder = ImmutableSet.builder(); for (int cpu = 1; cpu <= maxCpuFromProperties; cpu++) { for (int ram = minRamFromProperties; ram <= maxRamFromProperties; ram *= 2) { builder.add(HardwareProfiles.createHardwareProfile(cpu, ram)); }/*from ww w. ja v a 2 s.c om*/ } // Predefined profiles, supplied explicitly by the user if (predefinedProfiles != null) { for (String profile : Splitter.on(",").trimResults().omitEmptyStrings().split(predefinedProfiles)) { builder.add(HardwareProfiles.createHardwareProfile(profile)); } } this.hardwareConfigs = builder.build(); }
From source file:org.caleydo.view.domino.api.model.typed.MultiTypedSet.java
@Override public Set<TypedID> asInhomogenous() { if (ids instanceof Single) return new SingleTypedIDSet(((Single) ids).set); ImmutableSet.Builder<TypedID> b = ImmutableSet.builder(); for (int i = 0; i < depth(); ++i) { IDType idType = idTypes[i];//from ww w .j a v a2 s . c o m // select just the slice and map to typed id b.addAll(Collections2.transform(ids, Functions.compose(TypedID.toTypedId(idType), slice(i)))); } return b.build(); }
From source file:com.google.inject.servlet.ServletSpiVisitor.java
ServletSpiVisitor(boolean forInjector) { ImmutableSet.Builder<Class> builder = ImmutableSet.builder(); // always ignore these things... builder.add(ServletRequest.class, ServletResponse.class, ManagedFilterPipeline.class, ManagedServletPipeline.class, FilterPipeline.class, ServletContext.class, HttpServletRequest.class, Filter.class, HttpServletResponse.class, HttpSession.class, Map.class, HttpServlet.class, InternalServletModule.BackwardsCompatibleServletContextProvider.class, GuiceFilter.class); if (forInjector) { // only ignore these if this is for the live injector, any other time it'd be an error! builder.add(Injector.class, Stage.class, Logger.class); }/* ww w.ja v a 2 s . c o m*/ this.allowedClasses = builder.build(); }