本文整理汇总了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);
}