Class PrefabValues
- java.lang.Object
-
- nl.jqno.equalsverifier.internal.prefabvalues.PrefabValues
-
public class PrefabValues extends Object
Container and creator of prefabricated instances of objects and classes.Only creates values ones, and caches them once they've been created. Takes generics into account; i.e.,
List<Integer>
is different fromList<String>
.
-
-
Constructor Summary
Constructors Constructor Description PrefabValues(FactoryCache factoryCache)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
giveBlue(TypeTag tag)
Returns the "blue" prefabricated value of the specified type.<T> T
giveOther(TypeTag tag, T value)
Returns a prefabricated value of the specified type, that is different from the specified value.<T> T
giveRed(TypeTag tag)
Returns the "red" prefabricated value of the specified type.<T> T
giveRedCopy(TypeTag tag)
Returns a shallow copy of the "red" prefabricated value of the specified type.<T> Tuple<T>
giveTuple(TypeTag tag)
Returns a tuple of two different prefabricated values of the specified type.<T> void
realizeCacheFor(TypeTag tag, LinkedHashSet<TypeTag> typeStack)
Makes sure that values for the specified type are present in the cache, but doesn't return them.
-
-
-
Constructor Detail
-
PrefabValues
public PrefabValues(FactoryCache factoryCache)
Constructor.- Parameters:
factoryCache
- The factories that can be used to create values.
-
-
Method Detail
-
giveRed
public <T> T giveRed(TypeTag tag)
Returns the "red" prefabricated value of the specified type.It's always a different value from the "blue" one.
- Type Parameters:
T
- The return value is cast to this type.- Parameters:
tag
- A description of the desired type, including generic parameters.- Returns:
- The "red" prefabricated value.
-
giveBlue
public <T> T giveBlue(TypeTag tag)
Returns the "blue" prefabricated value of the specified type.It's always a different value from the "red" one.
- Type Parameters:
T
- The return value is cast to this type.- Parameters:
tag
- A description of the desired type, including generic parameters.- Returns:
- The "blue" prefabricated value.
-
giveRedCopy
public <T> T giveRedCopy(TypeTag tag)
Returns a shallow copy of the "red" prefabricated value of the specified type.When possible, it's equal to but not the same as the "red" object.
- Type Parameters:
T
- The return value is cast to this type.- Parameters:
tag
- A description of the desired type, including generic parameters.- Returns:
- A shallow copy of the "red" prefabricated value.
-
giveTuple
public <T> Tuple<T> giveTuple(TypeTag tag)
Returns a tuple of two different prefabricated values of the specified type.- Type Parameters:
T
- The returned tuple will have this generic type.- Parameters:
tag
- A description of the desired type, including generic parameters.- Returns:
- A tuple of two different values of the given type.
-
giveOther
public <T> T giveOther(TypeTag tag, T value)
Returns a prefabricated value of the specified type, that is different from the specified value.- Type Parameters:
T
- The type of the value.- Parameters:
tag
- A description of the desired type, including generic parameters.value
- A value that is different from the value that will be returned.- Returns:
- A value that is different from
value
.
-
realizeCacheFor
public <T> void realizeCacheFor(TypeTag tag, LinkedHashSet<TypeTag> typeStack)
Makes sure that values for the specified type are present in the cache, but doesn't return them.- Type Parameters:
T
- The desired type.- Parameters:
tag
- A description of the desired type, including generic parameters.typeStack
- Keeps track of recursion in the type.
-
-