List of usage examples for com.google.common.collect ImmutableSet.Builder add
boolean add(E e);
From source file:org.gradle.internal.component.external.model.AbstractLazyModuleComponentResolveMetadata.java
private void populateHierarchy(Configuration metadata, ImmutableSet.Builder<String> accumulator) { accumulator.add(metadata.getName()); for (String parentName : metadata.getExtendsFrom()) { Configuration parent = configurationDefinitions.get(parentName); populateHierarchy(parent, accumulator); }/* w ww . j a va2 s.c o m*/ }
From source file:org.jclouds.googlecomputeengine.compute.functions.MachineTypeInZoneToHardware.java
private Iterable<Volume> collectVolumes(MachineType input) { ImmutableSet.Builder<Volume> volumes = ImmutableSet.builder(); for (MachineType.ScratchDisk disk : input.getScratchDisks()) { volumes.add(new VolumeBuilder().type(Volume.Type.LOCAL).size(new Integer(disk.getDiskGb()).floatValue()) .bootDevice(true).durable(false).build()); }//from w w w . j av a 2s . co m return volumes.build(); }
From source file:com.twitter.aurora.scheduler.configuration.ParsedConfiguration.java
/** * Constructs a ParsedConfiguration object and populates the set of {@link TaskConfig}s for * the provided config./*w w w.ja v a2s . co m*/ * * @param parsed A parsed {@link JobConfiguration}. */ @VisibleForTesting public ParsedConfiguration(JobConfiguration parsed) { this.parsed = parsed; ImmutableSet.Builder<TaskConfig> builder = ImmutableSet.builder(); for (int i = 0; i < parsed.getShardCount(); i++) { builder.add(parsed.getTaskConfig().deepCopy().setShardId(i)); } this.tasks = builder.build(); }
From source file:me.taylorkelly.mywarp.bukkit.BukkitGame.java
@Override public ImmutableSet<LocalWorld> getWorlds() { ImmutableSet.Builder<LocalWorld> builder = ImmutableSet.builder(); for (World world : Bukkit.getWorlds()) { builder.add(adapter.adapt(world)); }/*from ww w . ja va 2 s. c om*/ return builder.build(); }
From source file:com.publictransitanalytics.scoregenerator.scoring.StoringMappingScoreCard.java
@Override public void scoreTask(final TaskIdentifier task, final Map<PointLocation, DynamicProgrammingRecord> stateMap) throws InterruptedException { final Set<PointLocation> reachedLocations = stateMap.keySet(); final Set<Sector> reachedSectors = reachedLocations.stream().map(location -> pointSectorMap.get(location)) .flatMap(Collection::stream).collect(Collectors.toSet()); final LogicalTask logicalTask = new LogicalTask(task.getTime(), task.getCenter().getLogicalCenter()); final ImmutableSet.Builder<ScoreMappingKey> keysBuilder = ImmutableSet.builder(); for (final Sector sector : reachedSectors) { keysBuilder.add(ScoreMappingKey.getWriteKey(sector.getIdentifier(), logicalTask.getTime().toString(), logicalTask.getCenter().getIdentifier())); }/* ww w. j a v a 2 s . co m*/ store.putAll(keysBuilder.build()); }
From source file:com.stackframe.sarariman.tasks.TasksImpl.java
public Set<Task> getAll() { try {//from w w w.j a v a2 s . co m Connection connection = dataSource.getConnection(); try { Statement s = connection.createStatement(); try { ResultSet r = s.executeQuery("SELECT id FROM tasks"); try { ImmutableSet.Builder<Task> builder = ImmutableSet.<Task>builder(); while (r.next()) { builder.add(get(r.getInt("id"))); } return builder.build(); } finally { r.close(); } } finally { s.close(); } } finally { connection.close(); } } catch (SQLException se) { throw new RuntimeException(se); } }
From source file:org.opendaylight.aaa.shiro.realm.mapping.impl.BestAttemptGroupToRolesMappingStrategy.java
@Override public Map<String, Set<String>> mapGroupsToRoles(final Collection<String> groupNames, final String delimiter, final Map<String, String> groupRolesMap) { final ImmutableMap.Builder<String, Set<String>> roleNamesBuilder = ImmutableMap.builder(); if (groupRolesMap != null) { for (String groupName : groupNames) { final String roleNamesString = groupRolesMap.get(groupName); LOG.debug("association discovered: groupName={} and roleNamesString={}", groupName, roleNamesString);//from w w w . j av a 2 s .c om if (roleNamesString != null) { final String[] roleNames = roleNamesString.split(delimiter); final ImmutableSet.Builder<String> rolesSet = ImmutableSet.builder(); for (String roleName : roleNames) { rolesSet.add(roleName); } roleNamesBuilder.put(groupName, rolesSet.build()); } } } else { LOG.info("groupRolesMap was unspecified; directly mapping LDAP groups instead: {}", groupNames); for (String groupName : groupNames) { final ImmutableSet.Builder<String> rolesSet = ImmutableSet.builder(); rolesSet.add(groupName); roleNamesBuilder.put(groupName, rolesSet.build()); } } return roleNamesBuilder.build(); }
From source file:com.facebook.buck.rules.AbstractTestRuleFactory.java
@Override public T newInstance(BuildRuleFactoryParams params) throws NoSuchBuildTargetException { T builder = super.newInstance(params); // labels/*from w w w . j a v a 2s. c o m*/ if (builder instanceof LabelsAttributeBuilder) { List<String> rawLabels = params.getOptionalListAttribute("labels"); ImmutableSet.Builder<Label> labelBuilder = new ImmutableSet.Builder<>(); for (String rawLabel : rawLabels) { Label label = new Label(rawLabel); labelBuilder.add(label); } ((LabelsAttributeBuilder) builder).setLabels(labelBuilder.build()); } return builder; }
From source file:com.facebook.buck.util.hashing.FilePathHashLoader.java
public FilePathHashLoader(Path defaultCellRoot, ImmutableSet<Path> assumeModifiedFiles, boolean allowSymlinks) throws IOException { this.defaultCellRoot = defaultCellRoot; this.allowSymlinks = allowSymlinks; ImmutableSet.Builder<Path> modifiedFilesBuilder = ImmutableSet.builder(); for (Path path : assumeModifiedFiles) { modifiedFilesBuilder.add(resolvePath(path)); }/* www . j a v a 2s. c o m*/ this.assumeModifiedFiles = modifiedFilesBuilder.build(); }
From source file:com.brighttag.agathon.dao.sdb.SdbCassandraRingDao.java
@Override public ImmutableSet<CassandraRing> findAll() { ImmutableSet.Builder<CassandraRing> ringBuilder = ImmutableSet.builder(); for (String ring : ringsProvider.get()) { ringBuilder.add(getByName(ring)); }//from ww w . j a v a 2s. c om return ringBuilder.build(); }