public class TypeComparators extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Map<Class<?>,T> |
typeHolder |
| Constructor and Description |
|---|
TypeComparators() |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Removes all registered entities.
|
Stream<Map.Entry<Class<?>,Comparator<?>>> |
comparatorByTypes()
Returns a sequence of all type-comparator pairs which the current holder supplies.
|
static TypeComparators |
defaultTypeComparators() |
Stream<Map.Entry<Class<?>,T>> |
entityByTypes()
Returns a sequence of all type-entity pairs which the current holder supplies.
|
boolean |
equals(Object o) |
T |
get(Class<?> clazz)
This method returns the most relevant entity for the given class.
|
Comparator<?> |
getComparatorForType(Class<?> clazz)
This method returns the most relevant comparator for the given class.
|
boolean |
hasComparatorForType(Class<?> type)
Checks, whether an any custom comparator is associated with the giving type.
|
boolean |
hasEntity(Class<?> type)
Checks, whether an entity is associated with the giving type.
|
int |
hashCode() |
boolean |
isEmpty() |
void |
put(Class<?> clazz,
T entity)
Puts the
entity for the given clazz. |
<T> void |
registerComparator(Class<T> clazz,
Comparator<? super T> comparator)
Puts the
comparator for the given clazz. |
String |
toString() |
public static TypeComparators defaultTypeComparators()
public Comparator<?> getComparatorForType(Class<?> clazz)
clazz.
The order of checks is the following:
1. If there is a registered comparator for clazz then this one is used
2. We check if there is a registered comparator for a superclass of clazz
3. We check if there is a registered comparator for an interface of clazzclazz - the class for which to find a comparatornull if no comparator could be foundpublic boolean hasComparatorForType(Class<?> type)
type - the type for which to check a comparatorpublic <T> void registerComparator(Class<T> clazz, Comparator<? super T> comparator)
comparator for the given clazz.T - the type of the objects for the comparatorclazz - the class for the comparatorcomparator - the comparator itselfpublic Stream<Map.Entry<Class<?>,Comparator<?>>> comparatorByTypes()
public T get(Class<?> clazz)
clazz.
The order of checks is the following:
1. If there is a registered entity for clazz then this one is used
2. We check if there is a registered entity for a superclass of clazz
3. We check if there is a registered entity for an interface of clazzclazz - the class for which to find a entitynull if on entity could be foundpublic void put(Class<?> clazz, T entity)
entity for the given clazz.clazz - the class for the comparatorentity - the entity itselfpublic boolean hasEntity(Class<?> type)
type - the type for which to check an entitypublic boolean isEmpty()
true is there are registered entities, false otherwisepublic void clear()
public Stream<Map.Entry<Class<?>,T>> entityByTypes()
Copyright © 2025. All rights reserved.