org.mule.devkit.model.code
Class Type

java.lang.Object
  extended by org.mule.devkit.model.code.Type
All Implemented Interfaces:
Comparable<Type>, Generable
Direct Known Subclasses:
PrimitiveType, TypeReference

public abstract class Type
extends Object
implements Generable, Comparable<Type>

A representation of a type in codeModel.

A type is always either primitive (PrimitiveType) or a reference type (TypeReference).


Constructor Summary
Type()
           
 
Method Summary
abstract  TypeReference array()
          Create an array type of this type.
 String binaryName()
          Gets the binary name of the type.
abstract  TypeReference boxify()
          If this class is a primitive type, return the boxed class.
 int compareTo(Type o)
          Compare two JTypes by FQCN, giving sorting precedence to types that belong to packages java and javax over all others.
 GeneratedExpression dotclass()
           
 Type elementType()
          If this is an array, returns the component type of the array.
 boolean equals(Object oth)
           
 Type erasure()
          Returns the erasure of this type.
abstract  String fullName()
          Gets the full name of the type.
 int hashCode()
           
 boolean isArray()
          Tell whether or not this is an array type.
 boolean isPrimitive()
          Tell whether or not this is a built-in primitive type, such as int or void.
 boolean isReference()
          Returns true if this is a referenced type.
abstract  String name()
          Gets the name of this type.
abstract  CodeModel owner()
          Gets the owner code model object.
static PrimitiveType parse(CodeModel codeModel, String typeName)
          Obtains a reference to the primitive type object from a type name.
 String toString()
           
abstract  Type unboxify()
          If this class is a wrapper type for a primitive, return the primitive type.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mule.devkit.model.code.Generable
generate
 

Constructor Detail

Type

public Type()
Method Detail

parse

public static PrimitiveType parse(CodeModel codeModel,
                                  String typeName)
Obtains a reference to the primitive type object from a type name.


owner

public abstract CodeModel owner()
Gets the owner code model object.


fullName

public abstract String fullName()
Gets the full name of the type.

See http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html#25430 for the details.

Returns:
Strings like "int", "java.lang.String", "java.io.File[]". Never null.

binaryName

public String binaryName()
Gets the binary name of the type.

See http://java.sun.com/docs/books/jls/third_edition/html/binaryComp.html#44909

Returns:
Name like "Foo$Bar", "int", "java.lang.String", "java.io.File[]". Never null.

name

public abstract String name()
Gets the name of this type.

Returns:
Names like "int", "void", "BigInteger".

array

public abstract TypeReference array()
Create an array type of this type.

This method is undefined for primitive void type, which doesn't have any corresponding array representation.

Returns:
A TypeReference representing the array type whose element type is this type

isArray

public boolean isArray()
Tell whether or not this is an array type.


isPrimitive

public boolean isPrimitive()
Tell whether or not this is a built-in primitive type, such as int or void.


boxify

public abstract TypeReference boxify()
If this class is a primitive type, return the boxed class. Otherwise return this.

For example, for "int", this method returns "java.lang.Integer".


unboxify

public abstract Type unboxify()
If this class is a wrapper type for a primitive, return the primitive type. Otherwise return this.

For example, for "java.lang.Integer", this method returns "int".


erasure

public Type erasure()
Returns the erasure of this type.


isReference

public final boolean isReference()
Returns true if this is a referenced type.


elementType

public Type elementType()
If this is an array, returns the component type of the array. (T of T[])


toString

public String toString()
Overrides:
toString in class Object

compareTo

public int compareTo(Type o)
Compare two JTypes by FQCN, giving sorting precedence to types that belong to packages java and javax over all others.

This method is used to sort generated import statments in a conventional way for readability.

Specified by:
compareTo in interface Comparable<Type>

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

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

dotclass

public final GeneratedExpression dotclass()


Copyright © 2010–2014 MuleSoft, Inc.. All rights reserved.