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
-
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 newFactoryCache
instance containing the factories fromthis
and from theother
cache.<T> void
put
(Class<?> type, PrefabValueFactory<T> factory) Adds the given factory to the cache and associates it with the given type.<T> void
put
(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, wait
Methods 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
null
if 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 newFactoryCache
instance containing the factories fromthis
and from theother
cache.- Parameters:
other
- The other cache- Returns:
- a new instance containing factories from
this
andother
-
iterator
Provides an iterator over all available factories.- Specified by:
iterator
in interfaceIterable<Map.Entry<String,
PrefabValueFactory<?>>>
-