Package com.jalios.jcms
Class QueryResultSet.ScoreComparator<T extends Publication>
java.lang.Object
com.jalios.jstore.BasicStorable.CdateComparator<T>
com.jalios.jcms.comparator.BasicComparator<T>
com.jalios.jcms.QueryResultSet.ScoreComparator<T>
- Type Parameters:
T- the type
- All Implemented Interfaces:
Comparator<T>
- Enclosing class:
QueryResultSet
public static class QueryResultSet.ScoreComparator<T extends Publication>
extends BasicComparator<T>
This
If two Storable have the same score, a "parent" compararator is used, default "parent" comparator is
Note: because a high score must be first, it behaves in the opposite way of what
Comparator compares two Objects using a score
retrieved from a map of Object to float. If two Storable have the same score, a "parent" compararator is used, default "parent" comparator is
MdateComparator. Note: because a high score must be first, it behaves in the opposite way of what
Comparator says see the
compare(Object, Object) method.- Since:
- jcms-5.5.0
- Author:
- Olivier Jaquemet
-
Nested Class Summary
Nested classes/interfaces inherited from class com.jalios.jcms.comparator.BasicComparator
BasicComparator.StringComparisonMethod -
Field Summary
FieldsFields inherited from class com.jalios.jcms.comparator.BasicComparator
channel, comparisonMethod, contextMap, language, locale -
Constructor Summary
ConstructorsConstructorDescriptionInitialize aScoreComparatorfrom the contextual information retrieved through ComparatorManager parameterScoreComparator(QueryResultSet resultSet, Comparator parentComparator) Initialize aScoreComparatorusing the given parentComparator, if null, default withMdateComparator. -
Method Summary
Methods inherited from class com.jalios.jcms.comparator.BasicComparator
compareStringMethods inherited from class com.jalios.jstore.BasicStorable.CdateComparator
compareDateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
PARENT_COMPARATOR
- See Also:
-
QUERY_RESULT_SET
- See Also:
-
-
Constructor Details
-
ScoreComparator
public ScoreComparator()Initialize aScoreComparatorfrom the contextual information retrieved through ComparatorManager parameter- A parent
Comparator, is retrieved using attributePARENT_COMPARATOR, if null, default withMdateComparator. - The
QueryResultSet, is retrieved using attributeQUERY_RESULT_SET, must not be null.
- Throws:
IllegalArgumentException- if QueryResultSet is null
- A parent
-
ScoreComparator
Initialize aScoreComparatorusing the given parentComparator, if null, default withMdateComparator.- Parameters:
resultSet- theQueryResultSetfrom which to retrieve score of eachPublication.parentComparator- theComparatorto use when score of comparedObjectare identical.- Throws:
IllegalArgumentException- if QueryResultSet is null
-
-
Method Details
-
compare
Compare two Object using their score from the QueryResulSet. If score are equals, use the parent Comparator.- Specified by:
comparein interfaceComparator<T extends Publication>- Overrides:
comparein classBasicStorable.CdateComparator<T extends Publication>- Returns:
- 1 when o1 has a lower score than o2, -1 when has o1 higher score than o2 and returns parentComparator.compare value when scores are equals.
-