Module nl.jqno.equalsverifier
Class UserPrefabValueCaches
java.lang.Object
nl.jqno.equalsverifier.internal.valueproviders.UserPrefabValueCaches
Contains various caches of prefab values, or of factories for prefab values.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionConstructor.privatePrivate copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanBeCached(Class<?> type) Whether instances oftypeshould be cached.copy()Copies the cache of this PrefabValueProvider into a new instance.<T> Func<T> getGeneric(Class<T> type) Retrieves a factory to construct prefabricated values from the generic cache.Tuple<?> Retrieves a tuple of prefabricated values from the regular cache.getResettable(Class<?> type) Retrieves a resettable tuple of prefabricated values from the regular cache.<T> voidRegisters a prefab value.<T> voidregisterGeneric(Class<T> type, Func.Func1<?, T> factory) Registers a generic prefab value of arity 1.<T> voidregisterGeneric(Class<T> type, Func.Func2<?, ?, T> factory) Registers a generic prefab value of arity 2.<T> voidregisterResettable(Class<T> type, Supplier<T> red, Supplier<T> blue, Supplier<T> redCopy) Registers a resettable prefab value.
-
Field Details
-
cache
-
supplierCache
-
genericCache
-
-
Constructor Details
-
UserPrefabValueCaches
public UserPrefabValueCaches()Constructor. -
UserPrefabValueCaches
Private copy constructor.- Parameters:
other- Theto copy.invalid reference
GenericPrefabValueProvider
-
-
Method Details
-
copy
Copies the cache of this PrefabValueProvider into a new instance.- Returns:
- A copy of this PrefabValueProvider.
-
register
Registers a prefab value.- Type Parameters:
T- The type of the instances.- Parameters:
type- The class of the prefabricated values.red- An instance ofT.blue- Another instance ofT, not equal tored.redCopy- An instance ofT, equal toredbut preferably not the same instance.
-
registerResettable
public <T> void registerResettable(Class<T> type, Supplier<T> red, Supplier<T> blue, Supplier<T> redCopy) Registers a resettable prefab value.- Type Parameters:
T- The type of the instances.- Parameters:
type- The class of the prefabricated values.red- A Supplier for an instance ofT.blue- A Supplier for another instance ofT, not equal tored.redCopy- A Supplier for an instance ofT, equal toredbut preferably not the same instance.
-
registerGeneric
Registers a generic prefab value of arity 1.- Type Parameters:
T- The class of the prefabricated value.- Parameters:
type- The class of the prefabricated value.factory- A factory that can turn generic values into an instance oftypewith the appropriate generic values.
-
registerGeneric
Registers a generic prefab value of arity 2.- Type Parameters:
T- The class of the prefabricated value.- Parameters:
type- The class of the prefabricated value.factory- A factory that can turn generic values into an instance oftypewith the appropriate generic values.
-
getPlain
Retrieves a tuple of prefabricated values from the regular cache.- Parameters:
type- The type of the desired prefabricated values.- Returns:
- A tuple of prefabricated values.
-
getResettable
Retrieves a resettable tuple of prefabricated values from the regular cache.- Parameters:
type- The type of the desired prefabricated values.- Returns:
- A resettable tuple of prefabricated values.
-
getGeneric
Retrieves a factory to construct prefabricated values from the generic cache.- Type Parameters:
T- The type of the desired prefabricated values.- Parameters:
type- The type of the desired prefabricated values.- Returns:
- A factory to construct prefabricated values.
-
canBeCached
Whether instances oftypeshould be cached.- Parameters:
type- The type whose instances should or should not be cached.- Returns:
- Whether or not the given type should be cached.
-