nl.jqno.equalsverifier.util
Class PrefabValues

java.lang.Object
  extended by nl.jqno.equalsverifier.util.PrefabValues

public class PrefabValues
extends Object

Container and creator of prefabricated instances of objects and classes.

Author:
Jan Ouwens

Constructor Summary
PrefabValues()
           
PrefabValues(StaticFieldValueStash stash)
           
 
Method Summary
 void backupToStash(Class<?> type)
           
 boolean contains(Class<?> type)
          Tests whether prefabricated values exist for the specified class.
<T> T
getBlack(Class<T> type)
          Getter for the "black" prefabricated value of the specified type.
 Object getOther(Class<?> type, Object value)
          Returns a prefabricated value for type which is not equal to value.
<T> T
getRed(Class<T> type)
          Getter for the "red" prefabricated value of the specified type.
<T> void
put(Class<T> type, T red, T black)
          Associates the specified values with the specified class in this collection of prefabricated values.
 void putAll(PrefabValues from)
          Copies all prefabricated values of the specified PrefabValues to this one.
 void putFor(Class<?> type)
          Creates instances for the specified type, and for the types of the fields contained within the specified type, recursively, and adds them.
 void restoreFromStash()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrefabValues

public PrefabValues()

PrefabValues

public PrefabValues(StaticFieldValueStash stash)
Method Detail

backupToStash

public void backupToStash(Class<?> type)

restoreFromStash

public void restoreFromStash()

put

public <T> void put(Class<T> type,
                    T red,
                    T black)
Associates the specified values with the specified class in this collection of prefabricated values.

Type Parameters:
T - The type of value to put into this PrefabValues.
Parameters:
type - The class of the values.
red - A value of type T.
black - Another value of type T.

putAll

public void putAll(PrefabValues from)
Copies all prefabricated values of the specified PrefabValues to this one.

Parameters:
from - Prefabricated values to be copied to this PrefabValues.

contains

public boolean contains(Class<?> type)
Tests whether prefabricated values exist for the specified class.

Parameters:
type - Class whose presence in this PrefabValues is to be tested.
Returns:
True if prefabricated values exist for the specified class.

getRed

public <T> T getRed(Class<T> type)
Getter for the "red" prefabricated value of the specified type.

Parameters:
type - Class for which to return the prefabricated value.
Returns:
The "red" prefabricated value for the specified type.

getBlack

public <T> T getBlack(Class<T> type)
Getter for the "black" prefabricated value of the specified type.

Parameters:
type - Class for which to return the prefabricated value.
Returns:
The "black" prefabricated value for the specified type.

getOther

public Object getOther(Class<?> type,
                       Object value)
Returns a prefabricated value for type which is not equal to value.

Parameters:
type - Class for which to return a prefabricated value.
value - An instance of type.
Returns:
A prefabricated value for type which is not equal to value.

putFor

public void putFor(Class<?> type)
Creates instances for the specified type, and for the types of the fields contained within the specified type, recursively, and adds them. Both created instances are guaranteed not to be equal to each other, but are not guaranteed to be non-null. However, nulls will be very rare.

Parameters:
type - The type to create prefabValues for.
Throws:
RecursionException - If recursion is detected.


Copyright © 2015. All Rights Reserved.