java.lang.Object
io.helidon.common.Weights
Weight utilities.
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
Find weight from class annotation, or return default if none found.static double
Find weight for an instance.static void
Sort 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
Weight
or the default provided
-
find
Find weight for an instance. First checks if instance isWeighted
. If so, uses the value from it. Then checks forWeight
annotation. 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 withWeight
and which applies a specified default weight if either or both classes lack the annotation.- Type Parameters:
S
- type of object being compared- Returns:
- comparator
-