@SuppressWarnings("unchecked")
Set<Field> candidateFields = getAllFields(embeddedIdClass, ReflectionUtils.withAnnotation(Order.class));
final List<Field> clusteringFields = FluentIterable.from(candidateFields).filter(new Predicate<Field>() {
@Override
public boolean apply(Field field) {
Order orderAnnotation = field.getAnnotation(Order.class);
return !filter.hasAnnotation(field, PartitionKey.class) && orderAnnotation.value() > 1;
}
}).toSortedList(new Comparator<Field>() {
@Override
public int compare(Field o1, Field o2) {
Order order1 = o1.getAnnotation(Order.class);
Order order2 = o2.getAnnotation(Order.class);
return new Integer(order1.value()).compareTo(new Integer(order2.value()));
}
});
for (Field clusteringField : clusteringFields) {
final Order order = clusteringField.getAnnotation(Order.class);
final String cqlColumnName = introspector.inferCQLColumnName(clusteringField, context.getClassNamingStrategy());
validateNotStaticColumn(clusteringField);
sortOrders.add(new ClusteringOrder(cqlColumnName, order.reversed() ? Sorting.DESC : Sorting.ASC));
}
return sortOrders;
}