List of usage examples for com.google.common.collect ImmutableSortedSet copyOf
public static <E extends Comparable<? super E>> ImmutableSortedSet<E> copyOf(E[] elements)
From source file:com.facebook.buck.java.JavaTestRule.java
@Override public RuleKey.Builder appendToRuleKey(RuleKey.Builder builder) throws IOException { ImmutableSortedSet<? extends BuildRule> srcUnderTest = ImmutableSortedSet.copyOf(sourceUnderTest); super.appendToRuleKey(builder).set("vmArgs", vmArgs).set("sourceUnderTest", srcUnderTest); return builder; }
From source file:com.facebook.buck.android.AaptPackageResources.java
@Override public RuleKey.Builder appendDetailsToRuleKey(RuleKey.Builder builder) { return builder.set("packageType", packageType.toString()).set("cpuFilters", ImmutableSortedSet.copyOf(cpuFilters).toString()); }
From source file:com.outerspacecat.icalendar.ExDate.java
/** * Creates a new exception date.//w w w. j a v a 2s. c o m * * @param dateTimes the exception date-times. Must be non {@code null}, * contain one or more elements, and all elements must be non * {@code null}. * @param timeZone the time zone of {@code dateTimes}. May be {@code null}. * @param extraParameters the extra parameters of the exception date. Must be * non {@code null}, all elements must be non {@code null}, may be * empty. */ public ExDate(final Iterable<LocalDateTime> dateTimes, final ZoneId timeZone, final Iterable<Parameter> extraParameters) { Preconditions.checkNotNull(dateTimes, "dateTimes required"); Preconditions.checkArgument(dateTimes.iterator().hasNext(), "dateTimes must be non empty"); for (LocalDateTime d : dateTimes) Preconditions.checkNotNull(d, "each date-time must be non null"); if (timeZone != null) Preconditions.checkArgument(ParameterValue.isValidValue(timeZone.getId()), "timeZone id cannot be represented in iCalendar: " + timeZone.getId()); this.dates = null; this.dateTimes = ImmutableSortedSet.copyOf(dateTimes); this.timeZone = timeZone; ImmutableMap.Builder<String, Parameter> extraParametersBuilder = ImmutableMap.builder(); for (Parameter param : extraParameters) extraParametersBuilder.put(param.getName(), param); this.extraParameters = extraParametersBuilder.build(); }
From source file:org.apache.calcite.util.EquivalenceSet.java
/** Returns a map of the canonical element in each equivalence class to the * set of elements in that class. The keys are sorted in natural order, as * are the elements within each key. */ public SortedMap<E, SortedSet<E>> map() { final TreeMultimap<E, E> multimap = TreeMultimap.create(); for (Map.Entry<E, E> entry : parents.entrySet()) { multimap.put(entry.getValue(), entry.getKey()); }// w w w . jav a 2 s.c om // Create an immutable copy. Keys and values remain in sorted order. final ImmutableSortedMap.Builder<E, SortedSet<E>> builder = ImmutableSortedMap.naturalOrder(); for (Map.Entry<E, Collection<E>> entry : multimap.asMap().entrySet()) { builder.put(entry.getKey(), ImmutableSortedSet.copyOf(entry.getValue())); } return builder.build(); }
From source file:com.opengamma.strata.basics.date.ImmutableHolidayCalendar.java
/** * Obtains an instance from a set of holiday dates and weekend days. * <p>/*from w w w.ja va 2 s .c o m*/ * The holiday dates will be extracted into a set with duplicates ignored. * The minimum supported date for query is the start of the year of the earliest holiday. * The maximum supported date for query is the end of the year of the latest holiday. * <p> * The weekend days may both be the same. * * @param id the identifier * @param holidays the set of holiday dates * @param firstWeekendDay the first weekend day * @param secondWeekendDay the second weekend day, may be same as first * @return the holiday calendar */ public static ImmutableHolidayCalendar of(HolidayCalendarId id, Iterable<LocalDate> holidays, DayOfWeek firstWeekendDay, DayOfWeek secondWeekendDay) { ImmutableSet<DayOfWeek> weekendDays = Sets.immutableEnumSet(firstWeekendDay, secondWeekendDay); return new ImmutableHolidayCalendar(id, ImmutableSortedSet.copyOf(holidays), weekendDays); }
From source file:de.tuberlin.uebb.jdae.transformation.Reduction.java
public Reduction(final Collection<Equation> equations) { final ImmutableList.Builder<GlobalEquation> be = ImmutableList.builder(); this.names = Maps.newTreeMap(); final Map<Unknown, Integer> layout = Maps.newTreeMap(); final TransitiveRelation<Unknown> equivalent = Relations.newTransitiveRelation(); for (Equation eq : equations) { for (Unknown unknown : eq.unknowns()) { final Unknown base = unknown.base(); final Integer order = layout.get(base); if (order == null || (unknown.der > order)) layout.put(base, unknown.der); }//from ww w .ja v a 2 s . c om if (eq instanceof Equality) { final Unknown l = ((Equality) eq).lhs; final Unknown r = ((Equality) eq).rhs; Unknown min = Ordering.natural().min(l, r); Unknown max = Ordering.natural().max(l, r); if (min.der == 0) { equivalent.relate(min, max); } } } final Navigator<Unknown> direct = equivalent.direct(); final Map<Unknown, Unknown> repres = Maps.newTreeMap(); for (Map.Entry<Unknown, Integer> entry : layout.entrySet()) { final Unknown base = entry.getKey(); final int max = entry.getValue(); final Unknown repr = Collections.max(Navigators.closure(direct, base), Ordering.natural()); for (int i = 0; i <= max; i++) { repres.put(base.der(i), repr.der(i)); } } final Function<Unknown, GlobalVariable> pack_dense = new Function<Unknown, GlobalVariable>() { final Map<Integer, Integer> mem = Maps.newTreeMap(); public GlobalVariable apply(Unknown u) { if (!mem.containsKey(u.nr)) { mem.put(u.nr, (mem.size() + 1)); names.put(mem.get(u.nr), u.name); } return new GlobalVariable(u.name, mem.get(u.nr), u.der); } }; ctxt = Maps.transformValues(repres, pack_dense); for (Equation eq : equations) { if (eq instanceof Equality) { final Unknown l = ((Equality) eq).lhs; final Unknown r = ((Equality) eq).rhs; final Unknown min = Ordering.natural().min(l, r); if (min.der != 0) be.add(eq.bind(ctxt)); } else { be.add(eq.bind(ctxt)); } } reduced = be.build(); this.unknowns = ImmutableSortedSet.copyOf(ctxt.values()); }
From source file:com.facebook.buck.extension.BuckExtension.java
@Override public List<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) { JavacOptions javacOptions = JavacOptions.builder().setJavaCompilerEnviornment(BUCK_ENV).build(); ImmutableSortedSet.Builder<Path> classpath = ImmutableSortedSet.naturalOrder(); ImmutableCollection<Path> depPaths = Classpaths.getClasspathEntries(this.deps).values(); classpath.addAll(depPaths);//from w w w .j a v a 2 s . c om readBuckClasspath(classpath); ImmutableSortedSet<Path> declaredClasspath = classpath.build(); ImmutableList.Builder<Step> steps = ImmutableList.builder(); steps.add(new MakeCleanDirectoryStep(working)); steps.add(new MkdirStep(output.getParent())); steps.add(new JavacInMemoryStep(working, ImmutableSortedSet.copyOf(srcs), /* transitive classpath */ ImmutableSortedSet.<Path>of(), declaredClasspath, javacOptions, Optional.of(abi), Optional.of(target.toString()), BuildDependencies.FIRST_ORDER_ONLY, Optional.<JavacStep.SuggestBuildRules>absent(), /* path to sources list */ Optional.<Path>absent())); steps.add(new CopyResourcesStep(target, resources, output, context.getJavaPackageFinder())); steps.add(new JarDirectoryStep(output, ImmutableSortedSet.<Path>naturalOrder().add(working).addAll(depPaths).build(), /* main class */ null, /* manifest file */ null)); return steps.build(); }
From source file:com.spotify.heroic.suggest.memory.MemoryBackend.java
@Override public AsyncFuture<TagValuesSuggest> tagValuesSuggest(TagValuesSuggest.Request request) { final Map<String, Set<String>> counts = new HashMap<>(); final OptionalLimit groupLimit = request.getGroupLimit(); try (final Stream<Series> series = lookupSeries(request.getFilter())) { series.forEach(s -> {//w w w .j a va 2s . c om for (final Map.Entry<String, String> e : s.getTags().entrySet()) { Set<String> c = counts.get(e.getKey()); if (c == null) { c = new HashSet<>(); counts.put(e.getKey(), c); } if (groupLimit.isGreaterOrEqual(c.size())) { continue; } c.add(e.getValue()); } }); } final List<TagValuesSuggest.Suggestion> suggestions = ImmutableList.copyOf(request.getLimit() .limitStream(counts.entrySet().stream()).map(e -> new TagValuesSuggest.Suggestion(e.getKey(), ImmutableSortedSet.copyOf(e.getValue()), false)) .iterator()); return async.resolved(TagValuesSuggest.of(suggestions, false)); }
From source file:com.facebook.buck.cxx.toolchain.linker.GnuLinker.java
/** * Write all undefined symbols given in {@code symbolFiles} into a linker script wrapped in * `EXTERN` commands./*from www .j av a2 s .c o m*/ * * @param target the name given to the {@link BuildRule} which creates the linker script. * @param symbolFiles * @return the list of arguments which pass the linker script containing the undefined symbols to * link. */ @Override public ImmutableList<Arg> createUndefinedSymbolsLinkerArgs(ProjectFilesystem projectFilesystem, BuildRuleParams baseParams, ActionGraphBuilder graphBuilder, SourcePathRuleFinder ruleFinder, BuildTarget target, ImmutableList<? extends SourcePath> symbolFiles) { UndefinedSymbolsLinkerScript rule = graphBuilder.addToIndex(new UndefinedSymbolsLinkerScript(target, projectFilesystem, baseParams .withDeclaredDeps(ImmutableSortedSet.copyOf(ruleFinder.filterBuildRuleInputs(symbolFiles))) .withoutExtraDeps(), symbolFiles)); return ImmutableList.of(SourcePathArg.of(rule.getSourcePathToOutput())); }
From source file:com.opengamma.id.ExternalIdBundle.java
/** * Obtains an {@code ExternalIdBundle} from a collection of identifiers. * /*w w w . j a v a 2s .c o m*/ * @param externalIds the collection of external identifiers, validated * @return the bundle, not null */ private static ExternalIdBundle create(final Iterable<ExternalId> externalIds) { return new ExternalIdBundle(ImmutableSortedSet.copyOf(externalIds)); }