本文整理匯總了Java中com.google.common.collect.Ordering.compound方法的典型用法代碼示例。如果您正苦於以下問題:Java Ordering.compound方法的具體用法?Java Ordering.compound怎麽用?Java Ordering.compound使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.collect.Ordering
的用法示例。
在下文中一共展示了Ordering.compound方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: arrayOrdering
import com.google.common.collect.Ordering; //導入方法依賴的package包/類
public static Ordering<Object[]> arrayOrdering(int[] position, boolean[] reverse, Boolean[] nullsFirst) {
if (position.length == 0) {
return arrayOrdering(position[0], reverse[0], nullsFirst[0]);
}
// TODO: if the reverse/nullsFirst flags are the same for all positions this could be optimized
// to use just one single "inner" Ordering instance that is re-used for all positions
List<Comparator<Object[]>> comparators = new ArrayList<>(position.length);
for (int i = 0, positionLength = position.length; i < positionLength; i++) {
comparators.add(arrayOrdering(position[i], reverse[i], nullsFirst[i]));
}
return Ordering.compound(comparators);
}
示例2: comparatorOf
import com.google.common.collect.Ordering; //導入方法依賴的package包/類
public static Ordering<Blob> comparatorOf(ImmutableList<String> currentOrdering) {
Preconditions.checkArgument(!currentOrdering.isEmpty(),"invalid ordering: %s",currentOrdering);
ImmutableList<Ordering<Blob>> all = currentOrdering.stream()
.map(p -> orderingFor(p))
.collect(ImmutableList.toImmutableList());
return Ordering.compound(all);
}