List of usage examples for com.google.common.collect ImmutableList.Builder add
boolean add(E e);
From source file:com.squareup.wire.schema.Extensions.java
static ImmutableList<ExtensionsElement> toElements(ImmutableList<Extensions> extensions) { ImmutableList.Builder<ExtensionsElement> elements = new ImmutableList.Builder<>(); for (Extensions extension : extensions) { elements.add(ExtensionsElement.create(extension.location, extension.start, extension.end, extension.documentation)); }/*from w w w . j a va2 s. c om*/ return elements.build(); }
From source file:com.tarvon.fractala.util.ProjectionUtils.java
/** * Creates a cosine lookup table for use in equirectangular projections. * <p>/*from w w w. ja v a 2s .c o m*/ * The returned array will be the same length as the provided width, and * will have the cosine value of each pixel at each location within the * array. * * @param width * the width of the image that will be created. * @return the table of cosine values for each width. * @see #createSineTable(int) */ public static ImmutableList<Double> createCosineTable(int width) { double factor = calculateAnglePerPixel(width); ImmutableList.Builder<Double> cos = ImmutableList.builder(); for (int i = 0; i < width; i++) { cos.add(Math.cos(i * factor)); } return cos.build(); }
From source file:com.tarvon.fractala.util.ProjectionUtils.java
/** * Creates a sine lookup table for use in equirectangular projections. * <p>/*from w ww .ja va 2s . c om*/ * The returned array will be the same length as the provided width, and * will have the sine value of each pixel at each location within the array. * * @param width * the width of the image that will be created. * @return the table of sine values for each width. * @see #createCosineTable(int) */ public static ImmutableList<Double> createSineTable(int width) { double factor = calculateAnglePerPixel(width); ImmutableList.Builder<Double> sin = ImmutableList.builder(); for (int i = 0; i < width; i++) { sin.add(Math.sin(i * factor)); } return sin.build(); }
From source file:com.google.template.soy.data.SoyValueConverterUtility.java
/** * Creates a new SoyList initialized from the given values. Values are converted eagerly. * * @param items A list of values.//from ww w .jav a 2 s . co m * @return A new SoyEasyList initialized from the given values. */ public static SoyList newList(Object... items) { ImmutableList.Builder<SoyValueProvider> builder = ImmutableList.builder(); for (Object o : items) { builder.add(INSTANCE.convert(o)); } return ListImpl.forProviderList(builder.build()); }
From source file:com.google.devtools.build.lib.rules.objc.J2ObjcLibrary.java
/** * Returns header search paths necessary to compile the J2ObjC-generated code from a single * target.//w w w .j a v a2s. c o m * * @param ruleContext the rule context * @param objcFileRootExecPath the exec path under which all J2ObjC-generated file resides * @param sourcesToTranslate the source files to be translated by J2ObjC in a single target */ public static Iterable<PathFragment> j2objcSourceHeaderSearchPaths(RuleContext ruleContext, PathFragment objcFileRootExecPath, Iterable<Artifact> sourcesToTranslate) { PathFragment genRoot = ruleContext.getConfiguration().getGenfilesFragment(); ImmutableList.Builder<PathFragment> headerSearchPaths = ImmutableList.builder(); headerSearchPaths.add(objcFileRootExecPath); // We add another header search path with gen root if we have generated sources to translate. for (Artifact sourceToTranslate : sourcesToTranslate) { if (!sourceToTranslate.isSourceArtifact()) { headerSearchPaths.add(new PathFragment(objcFileRootExecPath, genRoot)); return headerSearchPaths.build(); } } return headerSearchPaths.build(); }
From source file:com.facebook.buck.rules.args.FileListableLinkerInputArg.java
public static ImmutableList<Arg> from(ImmutableList<SourcePathArg> values) { ImmutableList.Builder<Arg> converted = ImmutableList.builder(); for (SourcePathArg arg : values) { converted.add(withSourcePathArg(arg)); }/*from www . j a va 2s. c o m*/ return converted.build(); }
From source file:com.spectralogic.ds3client.utils.ResponseUtils.java
public static ImmutableList<Integer> toImmutableIntList(final int[] expectedStatuses) { final ImmutableList.Builder<Integer> integerBuilder = ImmutableList.builder(); if (expectedStatuses != null) { for (final int status : expectedStatuses) { integerBuilder.add(status); }/*w w w .j a va 2 s .c o m*/ } return integerBuilder.build(); }
From source file:org.xacml4j.v30.spi.pip.DefaultResolverContext.java
private static List<BagOfAttributeExp> evaluateKeys(EvaluationContext context, List<AttributeReferenceKey> keyRefs) throws EvaluationException { if (keyRefs == null) { return ImmutableList.of(); }//from w ww . j a v a 2 s. c o m ImmutableList.Builder<BagOfAttributeExp> b = ImmutableList.builder(); for (AttributeReferenceKey ref : keyRefs) { b.add(ref.resolve(context)); } return b.build(); }
From source file:com.github.imasahiro.stringformatter.processor.specifier.StringFormatConversionType.java
private static String convertToFormattableFlags(Set<FormatFlag> flags) { ImmutableList.Builder<Integer> flagBuilder = ImmutableList.builder(); if (flags.contains(FormatFlag.UPPER_CASE)) { flagBuilder.add(FormattableFlags.UPPERCASE); }/*from w w w. jav a2 s. com*/ if (flags.contains(FormatFlag.SHARP)) { flagBuilder.add(FormattableFlags.ALTERNATE); } if (flags.contains(FormatFlag.MINUS)) { flagBuilder.add(FormattableFlags.LEFT_JUSTIFY); } ImmutableList<Integer> formatterFlags = flagBuilder.build(); if (formatterFlags.isEmpty()) { formatterFlags = ImmutableList.of(0); } return Joiner.on("|").join(formatterFlags); }
From source file:com.google.devtools.build.xcode.xcodegen.testing.PbxTypes.java
/** * Transforms the given list of references into their string path representations. *///from ww w . j a v a 2 s . c om public static ImmutableList<String> paths(Iterable<? extends PBXReference> references) { ImmutableList.Builder<String> paths = ImmutableList.builder(); for (PBXReference reference : references) { paths.add(reference.getPath()); } return paths.build(); }