List of usage examples for com.google.common.collect Ordering natural
@GwtCompatible(serializable = true) @SuppressWarnings("unchecked") public static <C extends Comparable> Ordering<C> natural()
From source file:google.registry.export.ExportConstants.java
/** Returns the names of kinds to include in datastore backups. */ public static ImmutableSet<String> getBackupKinds() { // Back up all entity classes that aren't annotated with @VirtualEntity (never even persisted // to datastore, so they can't be backed up) or @NotBackedUp (intentionally omitted). return FluentIterable.from(EntityClasses.ALL_CLASSES).filter(not(hasAnnotation(VirtualEntity.class))) .filter(not(hasAnnotation(NotBackedUp.class))).transform(CLASS_TO_KIND_FUNCTION) .toSortedSet(Ordering.natural()); }
From source file:com.b2international.commons.validation.ConstraintViolations.java
/** * Formats the given set of {@link ConstraintViolation} to a list of * readable format./*from w w w . j a va 2 s. c om*/ * * @param violations * @return */ public static ImmutableList<String> format(Collection<? extends ConstraintViolation<?>> violations) { final Set<String> errors = Sets.newHashSet(); for (ConstraintViolation<?> v : violations) { errors.add(format(v)); } return ImmutableList.copyOf(Ordering.natural().sortedCopy(errors)); }
From source file:org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.ActionComparator.java
@Override public int compare(Action arg0, Action arg1) { return ComparisonChain.start().compare(arg0.getOrder(), arg1.getOrder(), Ordering.natural().nullsLast()) .result();/*w w w. j av a2 s. co m*/ }
From source file:com.anhth12.eval.ConfusionMatrix.java
/** * Creates an empty confusion Matrix/*from w ww . j a v a 2s . co m*/ */ public ConfusionMatrix() { this.matrix = new HashMap<>(); this.classes = new TreeSet<>(Ordering.natural().nullsFirst()); }
From source file:org.apache.calcite.test.MongoAssertions.java
/** * Similar to {@link CalciteAssert#checkResultUnordered}, but filters strings * before comparing them./*from w w w. ja v a2 s . c om*/ * * @param lines Expected expressions * @return validation function */ public static Consumer<ResultSet> checkResultUnordered(final String... lines) { return resultSet -> { try { final List<String> expectedList = Ordering.natural().immutableSortedCopy(Arrays.asList(lines)); final List<String> actualList = new ArrayList<>(); CalciteAssert.toStringList(resultSet, actualList); for (int i = 0; i < actualList.size(); i++) { String s = actualList.get(i); actualList.set(i, s.replaceAll("\\.0;", ";").replaceAll("\\.0$", "")); } Collections.sort(actualList); assertThat(Ordering.natural().immutableSortedCopy(actualList), equalTo(expectedList)); } catch (SQLException e) { throw TestUtil.rethrow(e); } }; }
From source file:com.analog.lyric.collect.SkipSet.java
/** * @since 0.05//from w ww . j av a 2 s .c o m */ public static @NonNull <T extends Comparable<T>> SkipSet<T> create() { return create(Ordering.natural()); }
From source file:de.flapdoodle.guava.Sort.java
public static <T, S extends Comparable<S>> List<T> sortBy(Iterable<T> source, Function<T, S> sortTransformation) { return sortBy(source, sortTransformation, Ordering.natural()); }
From source file:com.google.errorprone.refaster.testdata.IfFallthroughTemplateExample.java
public Comparator<String> example1() { return new Comparator<String>() { @Override// w ww.java 2 s . c o m public int compare(String o1, String o2) { return Ordering.natural().nullsFirst().compare(o1, o2); } }; }
From source file:dmg.util.command.AnnotatedCommandUtils.java
/** * Returns the option fields grouped by category of a given command class. *//* w w w . j ava 2 s . co m*/ public static Multimap<String, Field> getOptionsByCategory(Class<?> clazz) { Multimap<String, Field> options = TreeMultimap.create(Ordering.natural(), Ordering.natural().onResultOf(GET_NAME)); for (Class<?> c = clazz; c != null; c = c.getSuperclass()) { for (Field field : c.getDeclaredFields()) { Option option = field.getAnnotation(Option.class); if (option != null) { options.put(option.category(), field); } CommandLine cmd = field.getAnnotation(CommandLine.class); if (cmd != null) { options.put(cmd.category(), field); } } } return options; }
From source file:org.eclipse.sirius.diagram.sequence.business.internal.RangeHelper.java
/** * Returns an ordering suitable to sort ranges by their lower bound. * /*www . jav a 2 s . co m*/ * @return an ordering suitable to sort ranges by their lower bound. */ public static Ordering<Range> lowerBoundOrdering() { return Ordering.natural().onResultOf(RangeHelper.lowerBoundFunction()); }