public class JPrimitiveType extends AbstractJType
JCodeModel, such as JCodeModel.BOOLEAN.| Modifier and Type | Field and Description |
|---|---|
static JPrimitiveType |
BOOLEAN |
static JPrimitiveType |
BYTE |
static JPrimitiveType |
CHAR |
static JPrimitiveType |
DOUBLE |
static JPrimitiveType |
FLOAT |
static JPrimitiveType |
INT |
static JPrimitiveType |
LONG |
static JPrimitiveType |
SHORT |
static JPrimitiveType |
VOID |
| Modifier | Constructor and Description |
|---|---|
protected |
JPrimitiveType(JCodeModel aOwner,
String sTypeName,
Class<?> aWrapper,
boolean bUseValueOf) |
| Modifier and Type | Method and Description |
|---|---|
JArrayClass |
array()
Create an array type of this type.
|
AbstractJClass |
boxify()
If this class is a primitive type, return the boxed class.
|
String |
fullName()
Gets the full name of the type.
|
void |
generate(JFormatter f) |
boolean |
isPrimitive()
Tell whether or not this is a built-in primitive type, such as int or void.
|
String |
name()
Gets the name of this type.
|
JCodeModel |
owner()
Gets the owner code model object.
|
AbstractJType |
unboxify()
Deprecated.
calling this method from
JPrimitiveType would be
meaningless, since it's always guaranteed to return
this. |
IJExpression |
unwrap(IJExpression aExpr)
Do the opposite of the wrap method.
|
boolean |
useValueOf() |
void |
useValueOf(boolean bUseValueOf)
Determine of
valueOf should be used or not. |
IJExpression |
wrap(IJExpression aExpr)
Wraps an expression of this type to the corresponding wrapper class.
|
binaryName, elementType, erasure, isArray, isAssignableFrom, isAssignableFrom, isError, isReference, parse, toStringpublic static final JPrimitiveType VOID
public static final JPrimitiveType BOOLEAN
public static final JPrimitiveType BYTE
public static final JPrimitiveType SHORT
public static final JPrimitiveType CHAR
public static final JPrimitiveType INT
public static final JPrimitiveType FLOAT
public static final JPrimitiveType LONG
public static final JPrimitiveType DOUBLE
@Nonnull public JCodeModel owner()
IJOwnednull.@Nonnull public String fullName()
AbstractJTypefullName in class AbstractJTypenull for unnamed classes.@Nonnull public String name()
AbstractJTypename in class AbstractJTypepublic boolean isPrimitive()
AbstractJTypeisPrimitive in class AbstractJTypetrue if this is a primitive type@Nonnull public JArrayClass array()
AbstractJTypearray in class AbstractJTypeJArrayClass representing the array type whose element
type is this type@Nonnull public AbstractJClass boxify()
AbstractJTypeFor example, for "int", this method returns "java.lang.Integer".
boxify in class AbstractJTypenull@Deprecated @Nonnull public AbstractJType unboxify()
JPrimitiveType would be
meaningless, since it's always guaranteed to return
this.AbstractJTypeFor example, for "java.lang.Integer", this method returns "int".
unboxify in class AbstractJTypenull@Nonnull public IJExpression wrap(@Nonnull IJExpression aExpr)
new Float(x) or Float.valueOf(x) for
the parameter x.IllegalStateException because this would
lead to corrupt code!aExpr - Expression to be wrappednulluseValueOf()@Nonnull public IJExpression unwrap(@Nonnull IJExpression aExpr)
Float object
x it creates x.floatValue()IllegalStateException because this would
lead to corrupt code!aExpr - Expression to be unwrappednullpublic boolean useValueOf()
true if valueOf should be used in
wrap(IJExpression), false if
new X(y) should be used there. Note:
valueOf is faster in execution since it uses
potentially built in caches of the objects.public void useValueOf(boolean bUseValueOf)
valueOf should be used or not.bUseValueOf - New value. true to enable usage of valueOfpublic void generate(@Nonnull JFormatter f)
Copyright © 2013–2015 Philip Helger. All rights reserved.