org.javaruntype.typedef
Class TypeDef

Object
  extended by org.javaruntype.typedef.TypeDef
All Implemented Interfaces:
Serializable

public final class TypeDef
extends Object
implements Serializable

This class represents a Type Definition. A Type Definition specifies which type parameters (if any) can a class take, and the relation that exists among them. It corresponds to the way a class can be defined in its .java file.

Examples of type definitions are:

These type definitions serve as a template for creating types (Type class), which resolve all type variables present in the type definition (for example, for a TypeDef object java.util.Collection<E> we can get a Type object java.util.Collection<java.lang.String>

Objects of this class are never created directly. To obtain a TypeDef object, the diverse methods in the TypeDefs class should be used.

Objects of this class are immutable, and thus thread-safe. Also, in order to avoid excessive memory usage, an internal synchronized cache exists which prevents the same TypeDef from being instantiated more than once (so, if two TypeDef objects are equal, this will mean that they are the same object).

Since:
1.0
Author:
Daniel Fernández
See Also:
Serialized Form

Method Summary
 boolean equals(Object obj)
           
 Class<?> getComponentClass()
          Returns the component class of the type definition.
 String getName()
          Returns the name of the type definition.
 TypeDefVariable[] getVariables()
          Returns the variables of the type definition.
 int hashCode()
           
 String toString()
           
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getComponentClass

public Class<?> getComponentClass()
Returns the component class of the type definition. For example, if the type definition is java.util.Collection<E>, this method will return java.lang.Class<java.util.Collection>

Returns:
the component class.

getVariables

public TypeDefVariable[] getVariables()
Returns the variables of the type definition.

Returns:
the type definition variables.

getName

public String getName()
Returns the name of the type definition. For example: "java.util.Collection<E>"

Returns:
the name of the type definition.

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © 2012 The JAVARUNTYPE team. All Rights Reserved.