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, forPrefabValues
.
-
-
Constructor Summary
Constructors Constructor Description FactoryCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(Class<?> type)
<T> PrefabValueFactory<T>
get(Class<T> type)
Retrieves the factory from the cache for the given type.Iterator<Map.Entry<String,PrefabValueFactory<?>>>
iterator()
Provides an iterator over all available factories.FactoryCache
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
-
-
-
-
Method Detail
-
put
public <T> void put(Class<?> type, PrefabValueFactory<T> factory)
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
public <T> void put(String typeName, PrefabValueFactory<T> factory)
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
public <T> PrefabValueFactory<T> get(Class<T> type)
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
public boolean contains(Class<?> type)
- Parameters:
type
- The type for which a factory is needed.- Returns:
- Whether a factory is available for the given type.
-
merge
public FactoryCache merge(FactoryCache other)
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
public Iterator<Map.Entry<String,PrefabValueFactory<?>>> iterator()
Provides an iterator over all available factories.- Specified by:
iterator
in interfaceIterable<Map.Entry<String,PrefabValueFactory<?>>>
-
-