List of usage examples for com.google.common.collect ImmutableList.Builder add
boolean add(E e);
From source file:com.google.devtools.build.lib.skyframe.ChainUniquenessUtils.java
private static ImmutableList<Object> canonicalize(ImmutableList<? extends Object> cycle) { int minPos = 0; String minString = cycle.get(0).toString(); for (int i = 1; i < cycle.size(); i++) { // TOOD(bazel-team): Is the toString representation stable enough? String candidateString = cycle.get(i).toString(); if (candidateString.compareTo(minString) < 0) { minPos = i;/*from w w w . j av a2 s . com*/ minString = candidateString; } } ImmutableList.Builder<Object> builder = ImmutableList.builder(); for (int i = 0; i < cycle.size(); i++) { int pos = (minPos + i) % cycle.size(); builder.add(cycle.get(pos)); } return builder.build(); }
From source file:com.facebook.presto.execution.SimpleDomain.java
private static List<SimpleRange> getSimpleRangeList(Domain domain) { checkNotNull(domain, "domain is null"); if (domain.isAll()) { return null; }/*w w w .j a v a 2 s . co m*/ if (domain.isNone()) { return ImmutableList.<SimpleRange>of(); } ImmutableList.Builder<SimpleRange> rangeBuilder = ImmutableList.builder(); for (Range range : domain.getRanges()) { rangeBuilder.add(SimpleRange.fromRange(range)); } return rangeBuilder.build(); }
From source file:net.maciekmm.personalTaxi.DestinationManagement.java
public static DestinationManagement fromConfig(ConfigurationSection section) { World world = Bukkit.getWorld(section.getString("world")); if (world == null) { throw new IllegalArgumentException( String.format("World %s is not available.", section.getString("world"))); }/*ww w . j a v a 2 s .co m*/ List<Map<?, ?>> destinations = section.getMapList("destinations"); ImmutableList.Builder<DestinationEntry> builder = new ImmutableList.Builder<>(); for (Map<?, ?> destination : destinations) { builder.add(DestinationEntry.fromConfig(world, new MemoryConfiguration().createSection("temporary", destination))); } return new DestinationManagement(world, builder.build()); }
From source file:org.tensorics.core.math.Operations.java
public static <V> List<V> performOnAll(Iterable<ValuePair<V>> valuePairs, BinaryOperation<V> operation) { ImmutableList.Builder<V> builder = ImmutableList.builder(); for (ValuePair<V> valuePair : valuePairs) { builder.add(operation.perform(valuePair.left(), valuePair.right())); }//from w w w .j a v a 2 s . co m return builder.build(); }
From source file:com.google.devtools.build.android.UnvalidatedAndroidDirectories.java
protected static ImmutableList<Path> splitPaths(String pathsString, FileSystem fileSystem) { if (pathsString.length() == 0) { return ImmutableList.of(); }/* w ww . j a v a2 s . co m*/ ImmutableList.Builder<Path> paths = new ImmutableList.Builder<>(); for (String pathString : pathsString.split("#")) { paths.add(exists(fileSystem.getPath(pathString))); } return paths.build(); }
From source file:com.facebook.buck.log.LogConfig.java
private static boolean addInputStreamForPath(Path path, ImmutableList.Builder<InputStream> inputStreamsBuilder) { try {/*w ww. j a va2s.c o m*/ inputStreamsBuilder.add(new FileInputStream(path.toString())); // Handle the case where a file doesn't end with a newline. inputStreamsBuilder.add(new ByteArrayInputStream(NEWLINE)); return true; } catch (FileNotFoundException e) { return false; } }
From source file:be.dnsbelgium.core.DomainName.java
public static DomainName of(String domainName) { String[] labels = StringUtils.splitPreserveAllTokens(domainName, '.'); ImmutableList.Builder<Label> builder = new ImmutableList.Builder<Label>(); for (String label : labels) { builder.add(Label.of(label)); }// w w w . j ava 2s .c o m return new DomainName(builder.build()); }
From source file:com.facebook.presto.atop.AtopTable.java
private static List<AtopColumn> baseColumnsAnd(AtopColumn... additionalColumns) { ImmutableList.Builder<AtopColumn> columns = ImmutableList.builder(); columns.add(HOST_IP); // 0th field is the label (i.e. table name) // 1st field is the name of the host, but isn't fully qualified columns.add(START_TIME);/* w ww . j a v a2 s . c o m*/ // 2nd field is the end timestamp as unix time columns.add(END_TIME); // 3rd field is the date, but we already have the epoch // 4th field is the time, but we already have the epoch // 5th field is the duration, and will be combined with 2 to compute start_time columns.addAll(Arrays.asList(additionalColumns)); return columns.build(); }
From source file:org.lanternpowered.server.data.util.DataUtil.java
public static List<DataView> getSerializedManipulatorList(Iterable<DataManipulator<?, ?>> manipulators) { checkNotNull(manipulators);//from www.j av a 2 s . c o m final ImmutableList.Builder<DataView> builder = ImmutableList.builder(); for (DataManipulator<?, ?> manipulator : manipulators) { builder.add(new MemoryDataContainer().set(DataQueries.DATA_CLASS, manipulator.getClass().getName()) .set(DataQueries.INTERNAL_DATA, manipulator.toContainer())); } return builder.build(); }
From source file:org.gradle.api.internal.artifacts.ivyservice.moduleconverter.DefaultLocalComponentMetadataBuilder.java
private static ImmutableCapabilities asImmutable(Collection<? extends Capability> descriptors) { if (descriptors.isEmpty()) { return ImmutableCapabilities.EMPTY; }/* w w w . j av a 2 s. c o m*/ ImmutableList.Builder<ImmutableCapability> builder = new ImmutableList.Builder<ImmutableCapability>(); for (Capability descriptor : descriptors) { builder.add( new ImmutableCapability(descriptor.getGroup(), descriptor.getName(), descriptor.getVersion())); } return new ImmutableCapabilities(builder.build()); }