Class TypeHelper
- java.lang.Object
-
- org.eclipse.persistence.jpa.jpql.tools.TypeHelper
-
public final class TypeHelper extends java.lang.Object
This helper contains methods related toIType
and can perform equivalency checks.- Version:
- 2.4
- Author:
- Pascal Filion
- Since:
- 2.3
-
-
Constructor Summary
Constructors Constructor Description TypeHelper(ITypeRepository typeRepository)
Creates a newTypeHelper
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IType
bigDecimal()
Retrieves theIType
forBigDecimal
.IType
bigInteger()
Retrieves theIType
forBigInteger
.IType
booleanType()
Retrieves theIType
forBoolean
.IType
byteType()
Retrieves theIType
forByte
.IType
characterType()
Retrieves theIType
forCharacter
.IType
collectionType()
Retrieves theIType
forCollection
.IType
convertPrimitive(IType type)
Converts the givenIType
, if it's representing a primitive type, into the class of the same type.IType
dateType()
Retrieves theIType
forDate
.IType
doubleType()
Retrieves theIType
forDouble
.IType
enumType()
Retrieves theIType
forEnum
.IType
floatType()
Retrieves theIType
forFloat
.IType
getType(java.lang.Class<?> type)
Returns theIType
of the given Java type.IType
getType(java.lang.String typeName)
Retrieves the external class for the given fully qualified class name.ITypeRepository
getTypeRepository()
Returns theITypeRepository
used by this helperIType
integerType()
Retrieves theIType
forInteger
.boolean
isBooleanType(IType type)
Determines whether the givenIType
is aBoolean
.boolean
isCollectionType(IType type)
Determines whether the givenIType
is an instance ofCollection
.boolean
isDateType(IType type)
boolean
isEnumType(IType type)
Determines whether the givenIType
is an instance ofEnum
.boolean
isFloatingType(IType type)
Determines whether the givenIType
is an instance of a floating type, which is eitherFloat
,Double
, float or double.boolean
isIntegralType(IType type)
Determines whether the givenIType
is an instance of a floating type, which is eitherInteger
,Long
, int or float.boolean
isMapType(IType type)
Determines whether the givenIType
is an instance ofMap
.boolean
isNumericType(IType type)
Determines whether the givenIType
is an instance ofNumber
.boolean
isObjectType(IType type)
Determines whether the givenIType
is the external form ofObject
.boolean
isPrimitiveType(IType type)
Determines whether the givenIType
represents a primitive type.boolean
isStringType(IType type)
Determines whether the givenIType
represents theString
class.IType
longType()
Retrieves theIType
forLong
.IType
longType(IType type)
Converts the givenIType
, if it's the primitive long, into theLong
type.IType
mapType()
Retrieves theIType
forMap
.IType
numberType()
Retrieves theIType
forNumber
.IType
objectType()
Retrieves theIType
forObject
.ITypeDeclaration
objectTypeDeclaration()
IType
primitiveBoolean()
Retrieves theIType
for the primitive boolean.IType
primitiveByte()
Retrieves theIType
for the primitive byte.IType
primitiveChar()
Retrieves theIType
for the primitive char.IType
primitiveDouble()
Retrieves theIType
for the primitive double.IType
primitiveFloat()
Retrieves theIType
for the primitive float.IType
primitiveInteger()
Retrieves theIType
for the primitive int.IType
primitiveLong()
Retrieves theIType
for the primitive long.IType
primitiveShort()
Retrieves theIType
for the primitive short.IType
shortType()
Retrieves theIType
forShort
.IType
stringType()
Retrieves theIType
forString
.IType
timestampType()
Retrieves theIType
forTimestamp
.IType
toBooleanType(IType type)
Converts the givenIType
, if it's the primitive boolean, into theBoolean
type.IType
toByteType(IType type)
Converts the givenIType
, if it's the primitive byte, into theByte
type.IType
toDoubleType(IType type)
Converts the givenIType
, if it's the primitive double, into theDouble
type.IType
toFloatType(IType type)
Converts the givenIType
, if it's the primitive float, into theFloat
type.IType
toIntegerType(IType type)
Converts the givenIType
, if it's the primitive int, into theInteger
type.IType
toShortType(IType type)
Converts the givenIType
, if it's the primitive short, into theShort
type.IType
unknownType()
Retrieves theIType
that represents an unknown type.ITypeDeclaration
unknownTypeDeclaration()
Returns theITypeDeclaration
for theIType
representing an unknown type.
-
-
-
Constructor Detail
-
TypeHelper
public TypeHelper(ITypeRepository typeRepository)
Creates a newTypeHelper
.- Parameters:
typeRepository
- The repository used to retrieve the types
-
-
Method Detail
-
bigDecimal
public IType bigDecimal()
Retrieves theIType
forBigDecimal
.- Returns:
- The external form of the
BigDecimal
class
-
bigInteger
public IType bigInteger()
Retrieves theIType
forBigInteger
.- Returns:
- The external form of the
BigInteger
class
-
booleanType
public IType booleanType()
Retrieves theIType
forBoolean
.- Returns:
- The external form of the
Boolean
class
-
byteType
public IType byteType()
Retrieves theIType
forByte
.- Returns:
- The external form of the
Byte
class
-
characterType
public IType characterType()
Retrieves theIType
forCharacter
.- Returns:
- The external form of the
Character
class
-
collectionType
public IType collectionType()
Retrieves theIType
forCollection
.- Returns:
- The external form of the
Collection
class
-
convertPrimitive
public IType convertPrimitive(IType type)
Converts the givenIType
, if it's representing a primitive type, into the class of the same type.- Parameters:
type
- Type to possibly convert from the primitive into the class- Returns:
- The given
IType
if it's not a primitive type otherwise the primitive type will have been converted into the class of that primitive
-
dateType
public IType dateType()
Retrieves theIType
forDate
.- Returns:
- The external form of the
Date
class
-
doubleType
public IType doubleType()
Retrieves theIType
forDouble
.- Returns:
- The external form of the
Double
class
-
enumType
public IType enumType()
Retrieves theIType
forEnum
.- Returns:
- The external form of the
Enum
class
-
floatType
public IType floatType()
Retrieves theIType
forFloat
.- Returns:
- The external form of the
Float
class
-
getType
public IType getType(java.lang.Class<?> type)
Returns theIType
of the given Java type.- Parameters:
type
- The Java type for which its external form will be returned- Returns:
- The
IType
representing the given Java type
-
getType
public IType getType(java.lang.String typeName)
Retrieves the external class for the given fully qualified class name.- Parameters:
typeName
- The fully qualified class name of the class to retrieve- Returns:
- The external form of the class to retrieve
-
getTypeRepository
public ITypeRepository getTypeRepository()
Returns theITypeRepository
used by this helper- Returns:
- The external form of the provider of
ITypes
.
-
integerType
public IType integerType()
Retrieves theIType
forInteger
.- Returns:
- The external form of the
Integer
class
-
isBooleanType
public boolean isBooleanType(IType type)
Determines whether the givenIType
is aBoolean
.- Parameters:
type
- The type to check it's assignability- Returns:
true
if the givenIType
is aBoolean
;false
otherwise
-
isCollectionType
public boolean isCollectionType(IType type)
Determines whether the givenIType
is an instance ofCollection
.- Parameters:
type
- The type to check it's assignability- Returns:
true
if the givenIType
is an instance ofCollection
;false
otherwise
-
isDateType
public boolean isDateType(IType type)
- Parameters:
type
- The type to check it's assignability- Returns:
true
if the givenIType
is aDate
,Timestamp
orCalendar
-
isEnumType
public boolean isEnumType(IType type)
Determines whether the givenIType
is an instance ofEnum
.- Parameters:
type
- The type to check it's assignability- Returns:
true
if the givenIType
is an instance ofEnum
;false
otherwise
-
isFloatingType
public boolean isFloatingType(IType type)
Determines whether the givenIType
is an instance of a floating type, which is eitherFloat
,Double
, float or double.- Parameters:
type
- The type to check it's assignability- Returns:
true
if the givenIType
is a floating type;false
otherwise
-
isIntegralType
public boolean isIntegralType(IType type)
Determines whether the givenIType
is an instance of a floating type, which is eitherInteger
,Long
, int or float.- Parameters:
type
- The type to check it's assignability- Returns:
true
if the givenIType
is a integral type;false
otherwise
-
isMapType
public boolean isMapType(IType type)
Determines whether the givenIType
is an instance ofMap
.- Parameters:
type
- The type to check it's assignability- Returns:
true
if the givenIType
is an instance ofMap
;false
otherwise
-
isNumericType
public boolean isNumericType(IType type)
Determines whether the givenIType
is an instance ofNumber
.- Parameters:
type
- The type to check it's assignability- Returns:
true
if the givenIType
is an instance ofNumber
;false
otherwise
-
isObjectType
public boolean isObjectType(IType type)
Determines whether the givenIType
is the external form ofObject
.- Parameters:
type
- The type to check it's assignability- Returns:
true
if the givenIType
is the external form ofObject
-
isPrimitiveType
public boolean isPrimitiveType(IType type)
Determines whether the givenIType
represents a primitive type.- Parameters:
type
- The type to check it's assignability- Returns:
true
if the givenIType
represents a primitive;false
otherwise
-
isStringType
public boolean isStringType(IType type)
Determines whether the givenIType
represents theString
class.- Parameters:
type
- The type to check it's assignability- Returns:
true
if the givenIType
represents theString
class;false
otherwise
-
longType
public IType longType()
Retrieves theIType
forLong
.- Returns:
- The external form of the
Long
class
-
longType
public IType longType(IType type)
Converts the givenIType
, if it's the primitive long, into theLong
type.
-
mapType
public IType mapType()
Retrieves theIType
forMap
.- Returns:
- The external form of the
Map
class
-
numberType
public IType numberType()
Retrieves theIType
forNumber
.- Returns:
- The external form of the
Number
class
-
objectType
public IType objectType()
Retrieves theIType
forObject
.- Returns:
- The external form of the
Object
class
-
objectTypeDeclaration
public ITypeDeclaration objectTypeDeclaration()
- Returns:
- The
ITypeDeclaration
of theObject
class
-
primitiveBoolean
public IType primitiveBoolean()
Retrieves theIType
for the primitive boolean.- Returns:
- The external form of the primitive boolean
-
primitiveByte
public IType primitiveByte()
Retrieves theIType
for the primitive byte.- Returns:
- The external form of the primitive byte
-
primitiveChar
public IType primitiveChar()
Retrieves theIType
for the primitive char.- Returns:
- The external form of the primitive char
-
primitiveDouble
public IType primitiveDouble()
Retrieves theIType
for the primitive double.- Returns:
- The external form of the primitive double
-
primitiveFloat
public IType primitiveFloat()
Retrieves theIType
for the primitive float.- Returns:
- The external form of the primitive float
-
primitiveInteger
public IType primitiveInteger()
Retrieves theIType
for the primitive int.- Returns:
- The external form of the primitive int
-
primitiveLong
public IType primitiveLong()
Retrieves theIType
for the primitive long.- Returns:
- The external form of the primitive long
-
primitiveShort
public IType primitiveShort()
Retrieves theIType
for the primitive short.- Returns:
- The external form of the primitive short
-
shortType
public IType shortType()
Retrieves theIType
forShort
.- Returns:
- The external form of the
Short
class
-
stringType
public IType stringType()
Retrieves theIType
forString
.- Returns:
- The external form of the
String
class
-
timestampType
public IType timestampType()
Retrieves theIType
forTimestamp
.- Returns:
- The external form of the
Timestamp
class
-
toBooleanType
public IType toBooleanType(IType type)
Converts the givenIType
, if it's the primitive boolean, into theBoolean
type.
-
toByteType
public IType toByteType(IType type)
Converts the givenIType
, if it's the primitive byte, into theByte
type.
-
toDoubleType
public IType toDoubleType(IType type)
Converts the givenIType
, if it's the primitive double, into theDouble
type.
-
toFloatType
public IType toFloatType(IType type)
Converts the givenIType
, if it's the primitive float, into theFloat
type.
-
toIntegerType
public IType toIntegerType(IType type)
Converts the givenIType
, if it's the primitive int, into theInteger
type.
-
toShortType
public IType toShortType(IType type)
Converts the givenIType
, if it's the primitive short, into theShort
type.
-
unknownType
public IType unknownType()
Retrieves theIType
that represents an unknown type.- Returns:
- The external form of an unknown type
-
unknownTypeDeclaration
public ITypeDeclaration unknownTypeDeclaration()
Returns theITypeDeclaration
for theIType
representing an unknown type.- Returns:
- The
ITypeDeclaration
of the unknown type
-
-