Class JPrimitiveType
java.lang.Object
com.sun.codemodel.JType
com.sun.codemodel.JPrimitiveType
- All Implemented Interfaces:
JGenerable, Comparable<JType>
Java built-in primitive types.
Instances of this class can be obtained as constants of
JCodeModel,
such as JCodeModel.BOOLEAN.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate JClassprivate final JCodeModelprivate final Stringprivate final JClassCorresponding wrapper class. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionarray()Create an array type of this type.boxify()Obtains the wrapper class for this primitive type.fullName()Gets the full name of the type.voidDeprecated.booleanTell whether or not this is a built-in primitive type, such as int or void.name()Gets the name of this type.owner()Gets the owner code model object.unboxify()Deprecated.calling this method fromJPrimitiveTypewould be meaningless, since it's always guaranteed to return this.unwrap(JExpression exp) Do the opposite of the wrap method.wrap(JExpression exp) Wraps an expression of this type to the corresponding wrapper class.Methods inherited from class JType
binaryName, compareTo, elementType, erasure, isArray, isReference, parse, toString
-
Field Details
-
typeName
-
owner
-
wrapperClass
Corresponding wrapper class. For example, this would be "java.lang.Short" for short. -
arrayClass
-
-
Constructor Details
-
JPrimitiveType
JPrimitiveType(JCodeModel owner, String typeName, Class<?> wrapper)
-
-
Method Details
-
owner
Description copied from class:JTypeGets the owner code model object. -
fullName
Description copied from class:JTypeGets the full name of the type. See http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html#25430 for the details. -
name
-
isPrimitive
public boolean isPrimitive()Description copied from class:JTypeTell whether or not this is a built-in primitive type, such as int or void.- Overrides:
isPrimitivein classJType
-
array
Description copied from class:JTypeCreate an array type of this type. This method is undefined for primitive void type, which doesn't have any corresponding array representation. -
boxify
-
unboxify
Deprecated.calling this method fromJPrimitiveTypewould be meaningless, since it's always guaranteed to return this.Description copied from class:JTypeIf 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".
-
getWrapperClass
-
wrap
Wraps an expression of this type to the corresponding wrapper class. For example, if this class represents "float", this method will return the expressionnew Float(x)for the paramter x. REVISIT: it's not clear how this method works for VOID. -
unwrap
Do the opposite of the wrap method. REVISIT: it's not clear how this method works for VOID. -
generate
-
boxify().