java.lang.Object
io.helidon.common.Weights
Weight utilities.
-
Method Summary
Modifier and TypeMethodDescriptionstatic doubleFind weight from class annotation, or return default if none found.static doubleFind weight for an instance.static voidSort the list based on weights.static <S> Comparator<S>
-
Method Details
-
find
Find weight from class annotation, or return default if none found.- Parameters:
aClass- class to analyzeddefaultWeight- default weight of this class- Returns:
- weight from
Weightor the default provided
-
find
Find weight for an instance. First checks if instance isWeighted. If so, uses the value from it. Then checks forWeightannotation. If none of the above is found, returns the default weight.- Parameters:
anObject- object to find weight fordefaultWeight- default weight to use- Returns:
- weight of the object or default provided
-
sort
Sort the list based on weights.- Parameters:
list- list to sort
-
weightComparator
Returns a comparator for two objects, the classes for which are implementations ofWeighted, and/or optionally annotated withWeightand which applies a specified default weight if either or both classes lack the annotation.- Type Parameters:
S- type of object being compared- Returns:
- comparator
-