List of usage examples for com.google.common.collect ImmutableSortedSet.Builder add
boolean add(E e);
From source file:google.registry.monitoring.metrics.LinearFitter.java
/** * Create a new {@link LinearFitter}.//from w w w . j a va 2s . c om * * @param numFiniteIntervals the number of intervals, excluding the underflow and overflow * intervals * @param width the width of each interval * @param offset the start value of the first interval * @throws IllegalArgumentException if {@code numFiniteIntervals <= 0} or {@code width <= 0} */ public static LinearFitter create(int numFiniteIntervals, double width, double offset) { checkArgument(numFiniteIntervals > 0, "numFiniteIntervals must be greater than 0"); checkArgument(width > 0, "width must be greater than 0"); checkDouble(offset); ImmutableSortedSet.Builder<Double> boundaries = ImmutableSortedSet.naturalOrder(); for (int i = 0; i < numFiniteIntervals + 1; i++) { boundaries.add(width * i + offset); } return new AutoValue_LinearFitter(width, offset, boundaries.build()); }
From source file:google.registry.monitoring.metrics.ExponentialFitter.java
/** * Create a new {@link ExponentialFitter}. * * @param numFiniteIntervals the number of intervals, excluding the underflow and overflow * intervals/* www . java2 s . c o m*/ * @param base the base of the exponent * @param scale a multiplicative factor for the exponential function * @throws IllegalArgumentException if {@code numFiniteIntervals <= 0}, {@code width <= 0} or * {@code base <= 1} */ public static ExponentialFitter create(int numFiniteIntervals, double base, double scale) { checkArgument(numFiniteIntervals > 0, "numFiniteIntervals must be greater than 0"); checkArgument(scale != 0, "scale must not be 0"); checkArgument(base > 1, "base must be greater than 1"); checkDouble(base); checkDouble(scale); ImmutableSortedSet.Builder<Double> boundaries = ImmutableSortedSet.naturalOrder(); for (int i = 0; i < numFiniteIntervals + 1; i++) { boundaries.add(scale * Math.pow(base, i)); } return new AutoValue_ExponentialFitter(base, scale, boundaries.build()); }
From source file:com.facebook.buck.test.result.groups.MockingDSL.java
static void deps(BuildRule buildRule, BuildRule... dependencies) { Comparator<BuildRule> comparator = new Comparator<BuildRule>() { @Override//from w w w .jav a 2s . c om public int compare(BuildRule o1, BuildRule o2) { return o1.hashCode() - o2.hashCode(); } }; ImmutableSortedSet.Builder<BuildRule> builder = ImmutableSortedSet.orderedBy(comparator); for (BuildRule dependency : dependencies) { builder.add(dependency); } ImmutableSortedSet<BuildRule> dependenciesSet = builder.build(); expect(buildRule.getDeps()).andReturn(dependenciesSet).anyTimes(); }
From source file:org.gradle.model.internal.type.ModelTypes.java
/** * Returns the sorted, unique display names of the given types. *//*from w w w. j ava 2 s.co m*/ public static Iterable<String> getDisplayNames(Iterable<? extends ModelType<?>> types) { ImmutableSortedSet.Builder<String> builder = ImmutableSortedSet.naturalOrder(); for (ModelType<?> type : types) { builder.add(type.getDisplayName()); } return builder.build(); }
From source file:com.facebook.buck.jvm.java.DirectToJarOutputSettingsSerializer.java
@SuppressWarnings("unchecked") public static DirectToJarOutputSettings deserialize(Map<String, Object> data) { Preconditions.checkArgument(data.containsKey(OUTPUT_PATH)); Preconditions.checkArgument(data.containsKey(CLASSES_TO_REMOVE)); Preconditions.checkArgument(data.containsKey(ENTRIES)); Path outputPath = Paths.get((String) data.get(OUTPUT_PATH)); ImmutableSet.Builder<Pattern> classesToRemove = ImmutableSet.builder(); for (Map<String, Object> patternData : (List<Map<String, Object>>) data.get(CLASSES_TO_REMOVE)) { Preconditions.checkArgument(patternData.containsKey(CLASSES_TO_REMOVE_PATTERN)); Preconditions.checkArgument(patternData.containsKey(CLASSES_TO_REMOVE_PATTERN_FLAGS)); classesToRemove.add(Pattern.compile((String) patternData.get(CLASSES_TO_REMOVE_PATTERN), (int) patternData.get(CLASSES_TO_REMOVE_PATTERN_FLAGS))); }// w w w . j a v a 2 s . c om ImmutableSortedSet.Builder<Path> entries = ImmutableSortedSet.naturalOrder(); for (String entry : (List<String>) data.get(ENTRIES)) { entries.add(Paths.get(entry)); } Optional<String> mainClass = Optional.empty(); if (data.containsKey(MAIN_CLASS)) { mainClass = Optional.of((String) data.get(MAIN_CLASS)); } Optional<Path> manifestFile = Optional.empty(); if (data.containsKey(MANIFEST_FILE)) { manifestFile = Optional.of(Paths.get((String) data.get(MANIFEST_FILE))); } return DirectToJarOutputSettings.of(outputPath, classesToRemove.build(), entries.build(), mainClass, manifestFile); }
From source file:com.facebook.buck.util.MorePaths.java
/** * Convert a set of input file paths as strings to {@link Path} objects. *//*from www. ja v a 2s .c o m*/ public static ImmutableSortedSet<Path> asPaths(Iterable<String> paths) { ImmutableSortedSet.Builder<Path> builder = ImmutableSortedSet.naturalOrder(); for (String path : paths) { builder.add(Paths.get(path)); } return builder.build(); }
From source file:com.facebook.buck.rules.BuildRules.java
public static ImmutableSortedSet<BuildRule> toBuildRulesFor(BuildTarget invokingBuildTarget, BuildRuleResolver ruleResolver, Iterable<BuildTarget> buildTargets, boolean allowNonExistentRule) { ImmutableSortedSet.Builder<BuildRule> buildRules = ImmutableSortedSet.naturalOrder(); for (BuildTarget target : buildTargets) { BuildRule buildRule = ruleResolver.get(target); if (buildRule != null) { buildRules.add(buildRule); } else if (!allowNonExistentRule) { throw new HumanReadableException("No rule for %s found when processing %s", target, invokingBuildTarget.getFullyQualifiedName()); }/* w ww.j a v a2 s . c om*/ } return buildRules.build(); }
From source file:com.facebook.buck.rules.InputRule.java
/** * Convert a set of input file paths to InputRules. *///from ww w. j ava2 s .com public static ImmutableSortedSet<InputRule> inputPathsAsInputRules(Iterable<String> paths, Function<String, String> pathRelativizer) { ImmutableSortedSet.Builder<InputRule> builder = ImmutableSortedSet.naturalOrder(); for (String path : paths) { builder.add(new InputRule(new File(pathRelativizer.apply(path)), path)); } return builder.build(); }
From source file:com.facebook.buck.apple.AppleDebuggableBinary.java
public static ImmutableSortedSet<BuildRule> getRequiredRuntimeDeps(AppleDebugFormat debugFormat, BuildRule strippedBinaryRule, ProvidesLinkedBinaryDeps unstrippedBinaryRule, Optional<AppleDsym> appleDsym) { if (debugFormat == AppleDebugFormat.NONE) { return ImmutableSortedSet.of(strippedBinaryRule); }// ww w . j a v a 2 s.c o m ImmutableSortedSet.Builder<BuildRule> builder = ImmutableSortedSet.naturalOrder(); if (debugFormat == AppleDebugFormat.DWARF) { builder.add(unstrippedBinaryRule); builder.addAll(unstrippedBinaryRule.getCompileDeps()); builder.addAll(unstrippedBinaryRule.getStaticLibraryDeps()); } else if (debugFormat == AppleDebugFormat.DWARF_AND_DSYM) { Preconditions.checkArgument(appleDsym.isPresent(), "debugFormat %s expects AppleDsym rule to be present", AppleDebugFormat.DWARF_AND_DSYM); builder.add(strippedBinaryRule); builder.add(appleDsym.get()); } return builder.build(); }
From source file:google.registry.rde.RdeResourceType.java
/** Returns set of resource type URIs included in a deposit {@code mode}. */ public static ImmutableSortedSet<String> getUris(RdeMode mode) { ImmutableSortedSet.Builder<String> builder = new ImmutableSortedSet.Builder<>(Ordering.natural()); for (RdeResourceType resourceType : RdeResourceType.values()) { if (resourceType.getModes().contains(mode)) { builder.add(resourceType.getUri()); }//from w w w . jav a 2s . c o m } return builder.build(); }