private static void checkUniqueHandlerPerCeTaskType(Multimap<String, CeTaskProcessor> permissiveIndex) { for (Map.Entry<String, Collection<CeTaskProcessor>> entry : permissiveIndex.asMap().entrySet()) { checkArgument( entry.getValue().size() == 1, format( "There can be only one CeTaskProcessor instance registered as the processor for CeTask type %s. " + "More than one found. Please fix your configuration: %s", entry.getKey(), COMMA_JOINER.join(from(entry.getValue()).transform(ToClassName.INSTANCE).toSortedList(CASE_INSENSITIVE_ORDER)))); } }
private static String formatLockString(Set<GuardedByExpression> locks) { ImmutableList<String> sortedUnhandled = FluentIterable.from(locks) .transform(Functions.toStringFunction()) .toSortedList(Comparator.naturalOrder()); return Joiner.on(", ").join(sortedUnhandled); }
public List<IdentityProvider> getAllEnabledAndSorted() { return from(providersByKey.values()) .filter(IsEnabledFilter.INSTANCE) .toSortedList( Ordering.natural().onResultOf(ToName.INSTANCE) ); }
/** * Returns "schema.json" files and sorts them based on their source set priorities. * * @return - schema files sorted by priority based on source set priority */ private List<File> getSchemaFilesFrom(Set<File> files) { return FluentIterable.from(files).filter(new Predicate<File>() { @Override public boolean apply(@Nullable File file) { return file != null && file.getName().equals(GraphQLSourceDirectorySet.SCHEMA_FILE_NAME); } }).toSortedList(new Comparator<File>() { @Override public int compare(File o1, File o2) { String sourceSet1 = getSourceSetNameFromFile(o1); String sourceSet2 = getSourceSetNameFromFile(o2); // negative because the sourceSets list is in reverse order return -(sourceSets.indexOf(sourceSet1) - sourceSets.indexOf(sourceSet2)); } }); }
public Set<ValueAttribute> computeConstructorArguments() { return ImmutableSet.copyOf( FluentIterable.from(getSettableAttributes()) .filter(Predicates.compose(Predicates.not(Predicates.equalTo(-1)), ToConstructorArgumentOrder.FUNCTION)) .toSortedList(Ordering.natural().onResultOf(ToConstructorArgumentOrder.FUNCTION))); }
public void testToSortedList_withComparator() { assertEquals( Lists.newArrayList(4, 3, 2, 1), fluent(4, 1, 3, 2).toSortedList(Ordering.<Integer>natural().reverse())); }
public void testToSortedList_withDuplicates() { assertEquals( Lists.newArrayList(4, 3, 1, 1), fluent(1, 4, 1, 3).toSortedList(Ordering.<Integer>natural().reverse())); }
CountDownLatch stopped) { List<ApolloModule> modulesSortedOnPriority = FluentIterable.from(modules) .toSortedList( Ordering.natural() .reverse()
public void initialize() throws InitializationException { assistants = FluentIterable.from(assistants).toSortedList(new Comparator<DataLoaderAssistant>() { public int compare(DataLoaderAssistant o1, DataLoaderAssistant o2) { return o2.priority() - o1.priority(); } }); } }
private static void checkUniqueHandlerPerCeTaskType(Multimap<String, CeTaskProcessor> permissiveIndex) { for (Map.Entry<String, Collection<CeTaskProcessor>> entry : permissiveIndex.asMap().entrySet()) { checkArgument( entry.getValue().size() == 1, format( "There can be only one CeTaskProcessor instance registered as the processor for CeTask type %s. " + "More than one found. Please fix your configuration: %s", entry.getKey(), COMMA_JOINER.join(from(entry.getValue()).transform(ToClassName.INSTANCE).toSortedList(CASE_INSENSITIVE_ORDER)))); } }
@Override public Iterator<TagView> iterator() { FluentIterable<TagView> iterable = FluentIterable .from(tagViews) .filter(displayEvenIfEmpty ? AcceptAll : FilterWhenEmpty); if (sorter != null) return iterable.toSortedList(sorter).iterator(); else return iterable.iterator(); }
public List<IdentityProvider> getAllEnabledAndSorted() { return from(providersByKey.values()) .filter(IsEnabledFilter.INSTANCE) .toSortedList( Ordering.natural().onResultOf(ToName.INSTANCE) ); }
private static String formatLockString(Set<GuardedByExpression> locks) { ImmutableList<String> sortedUnhandled = FluentIterable.from(locks) .transform(Functions.toStringFunction()) .toSortedList(Ordering.natural()); return Joiner.on(", ").join(sortedUnhandled); }
private List<Link> getNaturalLinks() { return FluentIterable.from(links).transform(new Function<Link, Link>() { @Nullable @Override public Link apply(@Nullable Link link) { return new Link(representationFactory, namespaceManager.currieHref(link.getRel()), link.getHref(), link.getName(), link.getTitle(), link.getHreflang(), link.getProfile()); } }).toSortedList(RELATABLE_ORDERING); }
private static List<NearMiss> sortAndTruncate(FluentIterable<NearMiss> nearMisses, int originalSize) { return nearMisses .toSortedList(NEAR_MISS_ASCENDING_COMPARATOR) .subList(0, min(NEAR_MISS_COUNT, originalSize)); }
/** * Return a List of POJOs representing a pair of deviation's cause and number of its occurrences. * * @param criteria * restrictions for deviations to be summarized. * @return ImmutableList of POJOs representing a pair of deviation's cause and number of its occurrences. */ public ImmutableList<DeviationWithOccurrencesCount> getDeviationsWithOccurrencesCount(final DeviationsReportCriteria criteria) { return FluentIterable.from(getMatchingOccurrencesProjection(criteria)).transform(DEVIATION_PROJECTION_TO_POJO) .toSortedList(DeviationCauseHolderComparators.BY_REASON_ASC); }
@Override public String get() { ImmutableMultimap<String, Supplier<String>> build = params.build(); if (!build.isEmpty()) { ImmutableList<String> values = FluentIterable.from(build.entries()) // .transform(TO_KEY_VALUE_PAIR) // .toSortedList(Ordering.natural()) // ; return path + "?" + Joiner.on("&").join(values); } return path; }
@Override public void read(DbFileSources.Line.Builder lineBuilder) { Predicate<Map.Entry<TextBlock, Integer>> containsLine = new TextBlockContainsLine(lineBuilder.getLine()); for (Integer textBlockIndex : from(duplicatedTextBlockIndexByTextBlock.entrySet()) .filter(containsLine) .transform(MapEntryToBlockId.INSTANCE) // list is sorted to cope with the non-guaranteed order of Map entries which would trigger false detection of changes // in {@link DbFileSources.Line#getDuplicationList()} .toSortedList(Ordering.natural())) { lineBuilder.addDuplication(textBlockIndex); } }
@Override public List<PolicySummary> list( final String application, final String entityToken ) { final Entity entity = brooklyn().getEntity(application, entityToken); return FluentIterable.from(entity.policies()) .transform(new Function<Policy, PolicySummary>() { @Override public PolicySummary apply(Policy policy) { return PolicyTransformer.policySummary(entity, policy, ui.getBaseUriBuilder()); } }) .toSortedList(SummaryComparators.nameComparator()); }
private void prepareSickNoteList(Person person, int year, Model model) { List<SickNote> sickNotes = sickNoteService.getByPersonAndPeriod(person, DateUtil.getFirstDayOfYear(year), DateUtil.getLastDayOfYear(year)); List<ExtendedSickNote> extendedSickNotes = FluentIterable.from(sickNotes) .transform(input -> new ExtendedSickNote(input, calendarService)).toSortedList((o1, o2) -> { // show latest sick notes at first return o2.getStartDate().compareTo(o1.getStartDate()); }); model.addAttribute("sickNotes", extendedSickNotes); SickDaysOverview sickDaysOverview = new SickDaysOverview(sickNotes, calendarService); model.addAttribute("sickDaysOverview", sickDaysOverview); }