Class FactoryCache
java.lang.Object
nl.jqno.equalsverifier.internal.prefabvalues.FactoryCache
- All Implemented Interfaces:
Iterable<Map.Entry<String,PrefabValueFactory<?>>>
public class FactoryCache
extends Object
implements Iterable<Map.Entry<String,PrefabValueFactory<?>>>
Contains a cache of factories, for
PrefabValues.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean<T> PrefabValueFactory<T>Retrieves the factory from the cache for the given type.iterator()Provides an iterator over all available factories.merge(FactoryCache other) Returns a newFactoryCacheinstance containing the factories fromthisand from theothercache.<T> voidput(Class<?> type, PrefabValueFactory<T> factory) Adds the given factory to the cache and associates it with the given type.<T> voidput(String typeName, PrefabValueFactory<T> factory) Adds the given factory to the cache and associates it with the given type name.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
FactoryCache
public FactoryCache()
-
-
Method Details
-
put
Adds the given factory to the cache and associates it with the given type.- Type Parameters:
T- The type of the factory.- Parameters:
type- The type to associate with the factory.factory- The factory to associate with the type.
-
put
Adds the given factory to the cache and associates it with the given type name.- Type Parameters:
T- Should matchtypeName.- Parameters:
typeName- The fully qualified name of the type.factory- The factory to associate withtypeName
-
get
Retrieves the factory from the cache for the given type.What happens when there is no factory, is undefined. Always call
contains(Class)first.- Type Parameters:
T- The returned factory will have this as generic type.- Parameters:
type- The type for which a factory is needed.- Returns:
- A factory for the given type, or
nullif none is available.
-
contains
- Parameters:
type- The type for which a factory is needed.- Returns:
- Whether a factory is available for the given type.
-
merge
Returns a newFactoryCacheinstance containing the factories fromthisand from theothercache.- Parameters:
other- The other cache- Returns:
- a new instance containing factories from
thisandother
-
iterator
Provides an iterator over all available factories.- Specified by:
iteratorin interfaceIterable<Map.Entry<String,PrefabValueFactory<?>>>
-