List of usage examples for com.google.common.collect Ordering from
@GwtCompatible(serializable = true) @Deprecated public static <T> Ordering<T> from(Ordering<T> ordering)
From source file:springfox.documentation.swagger2.mappers.Properties.java
static Ordering<String> defaultOrdering(Map<String, ModelProperty> properties) { return Ordering.from(byPosition(properties)).compound(byName()); }
From source file:me.emily.config.ProtocolConfig.java
private ImmutableList<Parser> getParsers() { String packageName = Parser.class.getPackage().getName(); Reflections r = new Reflections( new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage(packageName))); List<Parser> parsers = Lists.newArrayList(); for (Class<? extends Parser> clazz : r.getSubTypesOf(Parser.class)) { try {/*from w w w.j a v a 2 s . co m*/ parsers.add(clazz.newInstance()); } catch (Exception e) { log.error("Failed to load parser {}", clazz.getName()); Throwables.propagate(e); } } ImmutableList<Parser> ret = Ordering.from(ParserPriority.PriorityComparator.instance) .immutableSortedCopy(parsers); for (Parser p : ret) { log.info("Parser: {}", p.getClass().getName()); } return ret; }
From source file:com.ehret.mixit.model.MembreFacade.java
public List<Member> getMembres(Context context, String typeAppel, String filtre) { switch (TypeFile.getTypeFile(typeAppel)) { case speaker: getMapMembres(context, TypeFile.members, membres); //Hack to load talk ConferenceFacade.getInstance().getTalks(context, null); List<Member> speakers = FluentIterable.from(filtrerMembre(membres, filtre)) .filter(new Predicate<Member>() { @Override//from ww w .ja va 2 s . c o m public boolean apply(Member input) { return input.isSpeaker(); } }).toList(); return Ordering.from(getComparatorByName()).sortedCopy(speakers); case members: getMapMembres(context, TypeFile.members, membres); return Ordering.from(getComparatorByName()).sortedCopy(filtrerMembre(membres, filtre)); case staff: getMapMembres(context, TypeFile.staff, staff); return Ordering.from(getComparatorByName()).sortedCopy(filtrerMembre(staff, filtre)); default: getMapMembres(context, TypeFile.sponsor, sponsors); return Ordering.from(getComparatorByDate()).compound(getComparatorByLevel()) .sortedCopy(filtrerMembre(sponsors, filtre)); } }
From source file:com.yahoo.elide.jsonapi.document.processors.SortProcessor.java
/** * Field comparator.//from w ww . j av a2 s . com * * @param field name of attribute field to compare, prefix with '-' to specify descending order * @return a comparison between resources for the given attribute field */ private Comparator<Resource> comparisonForField(String field) { // Determine if ascending or descending if (field.charAt(0) == DESCENDING_TOKEN) { // Remove descending token to get field name String parsedField = field.substring(1); return Ordering.from(attributeComparison(parsedField)).nullsFirst().reverse(); } else { return Ordering.from(attributeComparison(field)).nullsFirst(); } }
From source file:org.kitesdk.data.spi.MarkerRange.java
public MarkerRange intersection(MarkerRange other) { Boundary newStart = Ordering.from(new Boundary.LeftComparator()).max(start, other.start); Boundary newEnd = Ordering.from(new Boundary.RightComparator()).min(end, other.end); return new MarkerRange(comparator, newStart, newEnd); }
From source file:org.onebusaway.nyc.vehicle_tracking.impl.inference.state.BlockState.java
/** * This compareTo method is for definite ordering in CategoricalDist; such * ordering allows for reproducibility in testing. *//*from ww w . j a v a 2s . com*/ @Override public int compareTo(BlockState rightBs) { if (this == rightBs) return 0; final int res = ComparisonChain.start().compare(this.destinationSignCode, rightBs.destinationSignCode) .compare(this.blockInstance, rightBs.blockInstance, Ordering.from(BlockInstanceComparator.INSTANCE)) .compare(this.blockLocation, rightBs.blockLocation, Ordering.from(ScheduledBlockLocationComparator.INSTANCE)) .compare(this.runTrip, rightBs.runTrip, Ordering.natural().nullsLast()).result(); return res; }
From source file:utils.teamcity.wallt.controller.configuration.ConfigurationController.java
private void updateSavedProjects() { final List<ProjectData> monitoredProjects = _projectManager.getMonitoredProjects(); final Ordering<ProjectData> ordering = Ordering.from(Comparator.comparingInt(_projectManager::getPosition)); final List<SavedProjectData> projectToSaved = ordering .sortedCopy(monitoredProjects).stream().map(data -> new SavedProjectData(data.getId(), data.getName(), data.getParentId().orElse(null), data.getAliasName())) .collect(Collectors.toList()); _configuration.setSavedProjects(projectToSaved); }
From source file:me.taylorkelly.mywarp.util.MatchList.java
/** * Gets a sorted immutable list that contains all warps matching this Matchers criteria. * * @param comparator the comparator used to sort the list * @return a list of all matches//from ww w . j a v a 2s . co m */ public ImmutableList<Warp> getMatches(Comparator<Warp> comparator) { return Ordering.from(comparator).immutableSortedCopy(matchingWarps); }
From source file:com.netxforge.netxstudio.server.logic.retention.AggregationEngine.java
public void intitialize(boolean re_initialize) { Resource resource = this.getDataProvider().getResource(MetricsPackage.Literals.METRIC_SOURCE); if (LogicActivator.DEBUG) { LogicActivator.TRACE.trace(LogicActivator.TRACE_RETENTION_OPTION, "Initializing Aggregation engine"); }//from w ww.j a v a 2 s .co m metricSources = new NonModelUtils.CollectionForObjects<MetricSource>() .collectionForObjects(resource.getContents()); // Rules should execute considering the order of the smallest // interval first, // as to allow aggregation. // Order the rules by smallest interval. if (metricRulesSortedList == null) { metricRulesSortedList = Ordering.from(StudioUtils.retentionRuleCompare()) .sortedCopy(rules.getMetricRetentionRules()); if (LogicActivator.DEBUG) { LogicActivator.TRACE.trace(LogicActivator.TRACE_RETENTION_OPTION, "Processing aggregation rule in order: "); for (MetricRetentionRule rule : metricRulesSortedList) { StringBuilder sb = new StringBuilder(); sb.append(rule.getName()); sb.append(" interval:" + rule.getIntervalHint()); sb.append(" rule: " + rule.getPeriod()); // sb.append(rule.getRetentionExpression() + " "); LogicActivator.TRACE.trace(LogicActivator.TRACE_RETENTION_OPTION, sb.toString()); } } } addonHandler.initializeModelAddon(re_initialize); }
From source file:org.sonar.server.measure.ws.ComponentTreeSort.java
private static Ordering<ComponentDto> stringOrdering(boolean isAscending, Function<ComponentDto, String> function) { Ordering<String> ordering = Ordering.from(CASE_INSENSITIVE_ORDER); if (!isAscending) { ordering = ordering.reverse();// w w w . j a va 2 s. c o m } return ordering.nullsLast().onResultOf(function); }