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:com.facebook.presto.cassandra.NativeCassandraSession.java
private static TableMetadata getTableMetadata(KeyspaceMetadata keyspace, String caseInsensitiveTableName) { TableMetadata result = null;// www . j av a2 s .c o m Collection<TableMetadata> tables = keyspace.getTables(); // Ensure that the error message is deterministic List<TableMetadata> sortedTables = Ordering.from(comparing(TableMetadata::getName)) .immutableSortedCopy(tables); for (TableMetadata table : sortedTables) { if (table.getName().equalsIgnoreCase(caseInsensitiveTableName)) { if (result != null) { throw new PrestoException(NOT_SUPPORTED, format( "More than one table has been found for the case insensitive table name: %s -> (%s, %s)", caseInsensitiveTableName, result.getName(), table.getName())); } result = table; } } if (result == null) { throw new TableNotFoundException(new SchemaTableName(keyspace.getName(), caseInsensitiveTableName)); } return result; }
From source file:org.jetbrains.kotlin.codegen.PackageCodegen.java
private void generatePackageFacadeClass(@NotNull Map<CallableMemberDescriptor, Runnable> tasks, @NotNull List<JvmSerializationBindings> bindings) { generateKotlinPackageReflectionField(); for (CallableMemberDescriptor member : Ordering.from(MemberComparator.INSTANCE) .sortedCopy(tasks.keySet())) { tasks.get(member).run();//from w ww . j a v a2s . c o m } bindings.add(v.getSerializationBindings()); writeKotlinPackageAnnotationIfNeeded(JvmSerializationBindings.union(bindings), tasks.keySet()); }
From source file:iterator.view.Editor.java
public Transform getTransformAt(Point point) { for (Transform t : Ordering.from(IFS.Z_ORDER).reverse().immutableSortedCopy(ifs)) { Shape box = t.getTransform().createTransformedShape(new Rectangle(0, 0, getWidth(), getHeight())); if (box.contains(point) || isResize(t, point) || isRotate(t, point)) { return t; }//from w ww .ja v a 2 s . com } return null; }
From source file:org.apache.druid.query.groupby.GroupByQuery.java
@Override public Ordering getResultOrdering() { final Ordering<Row> rowOrdering = getRowOrdering(false); return Ordering.from((lhs, rhs) -> { if (lhs instanceof Row) { return rowOrdering.compare((Row) lhs, (Row) rhs); } else {//from ww w . jav a2 s . c om // Probably bySegment queries return ((Ordering) Comparators.naturalNullsFirst()).compare(lhs, rhs); } }); }
From source file:io.prestosql.plugin.cassandra.NativeCassandraSession.java
private KeyspaceMetadata getKeyspaceByCaseInsensitiveName(String caseInsensitiveSchemaName) throws SchemaNotFoundException { List<KeyspaceMetadata> keyspaces = executeWithSession( session -> session.getCluster().getMetadata().getKeyspaces()); KeyspaceMetadata result = null;//ww w. j a v a2 s. c o m // Ensure that the error message is deterministic List<KeyspaceMetadata> sortedKeyspaces = Ordering.from(comparing(KeyspaceMetadata::getName)) .immutableSortedCopy(keyspaces); for (KeyspaceMetadata keyspace : sortedKeyspaces) { if (keyspace.getName().equalsIgnoreCase(caseInsensitiveSchemaName)) { if (result != null) { throw new PrestoException(NOT_SUPPORTED, format( "More than one keyspace has been found for the case insensitive schema name: %s -> (%s, %s)", caseInsensitiveSchemaName, result.getName(), keyspace.getName())); } result = keyspace; } } if (result == null) { throw new SchemaNotFoundException(caseInsensitiveSchemaName); } return result; }
From source file:org.lareferencia.backend.util.datatable.DataTable.java
/** * Returns a sorted list of distinct table cells in the specified column. * The cells are sorted according to the given comparator in ascending order. * * @param columnIndex The index of the required column. * @param comparator A Comparator for TableCells. * * @return A sorted list of distinct table cells in the specified column. *///from w w w .ja v a 2 s . c o m public List<TableCell> getColumnDistinctCellsSorted(int columnIndex, Comparator<TableCell> comparator) { // Get only the distinct Table cells (based on the comparator) Set<TableCell> colCells = Sets.newTreeSet(comparator); for (TableCell cell : getColumnCells(columnIndex)) { colCells.add(cell); } // Return the list of distinct Table cells sorted (based on the comparator). return Ordering.from(comparator).sortedCopy(colCells); }
From source file:org.bin01.db.verifier.Validator.java
private static Comparator<List<Object>> rowComparator() { final Comparator<Object> comparator = Ordering.from(columnComparator()).nullsFirst(); return new Comparator<List<Object>>() { @Override//from w w w .j av a 2 s .c om public int compare(List<Object> a, List<Object> b) { if (a.size() != b.size()) { return Integer.compare(a.size(), b.size()); } for (int i = 0; i < a.size(); i++) { int r = comparator.compare(a.get(i), b.get(i)); if (r != 0) { return r; } } return 0; } }; }
From source file:org.sonar.server.component.ws.TreeAction.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();/*from w w w . ja v a 2 s. c o m*/ } return ordering.nullsLast().onResultOf(function); }
From source file:org.apache.brooklyn.core.typereg.RegisteredTypes.java
public static RegisteredType getBestVersion(Iterable<RegisteredType> types) { if (types == null || !types.iterator().hasNext()) return null; return Ordering.from(RegisteredTypeComparator.INSTANCE).max(types); }
From source file:com.iorga.webappwatcher.analyzer.model.session.RequestsTimesAndStacks.java
public List<RequestTimes> createSortedRequestByDescendantMeanList() { return Ordering.from(new Comparator<RequestTimes>() { @Override//from ww w . ja v a 2 s. co m public int compare(final RequestTimes o1, final RequestTimes o2) { return new Double(o1.statistics.getMean()).compareTo(new Double(o2.statistics.getMean())); } }).reverse().sortedCopy(requestsByUrl.values()); }