nl.jqno.equalsverifier.util
Class Instantiator<T>

java.lang.Object
  extended by nl.jqno.equalsverifier.util.Instantiator<T>
Type Parameters:
T - Instantiator instantiates objects of this class, or of an anonymous subclass of this class.

public class Instantiator<T>
extends Object

Instantiates objects of a given class.

Author:
Jan Ouwens

Method Summary
 T instantiate()
          Instantiates an object of type T.
 T instantiateAnonymousSubclass()
          Instantiates an anonymous subclass of T.
static
<T> Instantiator<T>
of(Class<T> type)
          Factory method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

of

public static <T> Instantiator<T> of(Class<T> type)
Factory method.

Type Parameters:
T - The class on which Instantiator operates.
Parameters:
type - The class on which Instantiator operates. Should be the same as T.
Returns:
An Instantiator for type.

instantiate

public T instantiate()
Instantiates an object of type T. All fields will be initialized to their initial values. I.e., 0 for ints, null for objects, etc.

Returns:
An object of type T.

instantiateAnonymousSubclass

public T instantiateAnonymousSubclass()
Instantiates an anonymous subclass of T. The subclass is generated dynamically.

Returns:
An instance of an anonymous subclass of T.


Copyright © 2015. All Rights Reserved.