Class TypeHelper


  • public final class TypeHelper
    extends java.lang.Object
    This helper contains methods related to IType and can perform equivalency checks.
    Version:
    2.4
    Author:
    Pascal Filion
    Since:
    2.3
    • Constructor Detail

      • TypeHelper

        public TypeHelper​(ITypeRepository typeRepository)
        Creates a new TypeHelper.
        Parameters:
        typeRepository - The repository used to retrieve the types
    • Method Detail

      • bigDecimal

        public IType bigDecimal()
        Retrieves the IType for BigDecimal.
        Returns:
        The external form of the BigDecimal class
      • bigInteger

        public IType bigInteger()
        Retrieves the IType for BigInteger.
        Returns:
        The external form of the BigInteger class
      • booleanType

        public IType booleanType()
        Retrieves the IType for Boolean.
        Returns:
        The external form of the Boolean class
      • byteType

        public IType byteType()
        Retrieves the IType for Byte.
        Returns:
        The external form of the Byte class
      • characterType

        public IType characterType()
        Retrieves the IType for Character.
        Returns:
        The external form of the Character class
      • collectionType

        public IType collectionType()
        Retrieves the IType for Collection.
        Returns:
        The external form of the Collection class
      • convertPrimitive

        public IType convertPrimitive​(IType type)
        Converts the given IType, 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 the IType for Date.
        Returns:
        The external form of the Date class
      • doubleType

        public IType doubleType()
        Retrieves the IType for Double.
        Returns:
        The external form of the Double class
      • enumType

        public IType enumType()
        Retrieves the IType for Enum.
        Returns:
        The external form of the Enum class
      • floatType

        public IType floatType()
        Retrieves the IType for Float.
        Returns:
        The external form of the Float class
      • getType

        public IType getType​(java.lang.Class<?> type)
        Returns the IType 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
      • integerType

        public IType integerType()
        Retrieves the IType for Integer.
        Returns:
        The external form of the Integer class
      • isBooleanType

        public boolean isBooleanType​(IType type)
        Determines whether the given IType is a Boolean.
        Parameters:
        type - The type to check it's assignability
        Returns:
        true if the given IType is a Boolean; false otherwise
      • isCollectionType

        public boolean isCollectionType​(IType type)
        Determines whether the given IType is an instance of Collection.
        Parameters:
        type - The type to check it's assignability
        Returns:
        true if the given IType is an instance of Collection; false otherwise
      • isDateType

        public boolean isDateType​(IType type)
        Determines whether the given IType is a Date, Timestamp or Calendar.
        Parameters:
        type - The type to check it's assignability
        Returns:
        true if the given IType is a Date, Timestamp or Calendar
      • isEnumType

        public boolean isEnumType​(IType type)
        Determines whether the given IType is an instance of Enum.
        Parameters:
        type - The type to check it's assignability
        Returns:
        true if the given IType is an instance of Enum; false otherwise
      • isFloatingType

        public boolean isFloatingType​(IType type)
        Determines whether the given IType is an instance of a floating type, which is either Float, Double, float or double.
        Parameters:
        type - The type to check it's assignability
        Returns:
        true if the given IType is a floating type; false otherwise
      • isIntegralType

        public boolean isIntegralType​(IType type)
        Determines whether the given IType is an instance of a floating type, which is either Integer, Long, int or float.
        Parameters:
        type - The type to check it's assignability
        Returns:
        true if the given IType is a integral type; false otherwise
      • isMapType

        public boolean isMapType​(IType type)
        Determines whether the given IType is an instance of Map.
        Parameters:
        type - The type to check it's assignability
        Returns:
        true if the given IType is an instance of Map; false otherwise
      • isNumericType

        public boolean isNumericType​(IType type)
        Determines whether the given IType is an instance of Number.
        Parameters:
        type - The type to check it's assignability
        Returns:
        true if the given IType is an instance of Number; false otherwise
      • isObjectType

        public boolean isObjectType​(IType type)
        Determines whether the given IType is the external form of Object.
        Parameters:
        type - The type to check it's assignability
        Returns:
        true if the given IType is the external form of Object
      • isPrimitiveType

        public boolean isPrimitiveType​(IType type)
        Determines whether the given IType represents a primitive type.
        Parameters:
        type - The type to check it's assignability
        Returns:
        true if the given IType represents a primitive; false otherwise
      • isStringType

        public boolean isStringType​(IType type)
        Determines whether the given IType represents the String class.
        Parameters:
        type - The type to check it's assignability
        Returns:
        true if the given IType represents the String class; false otherwise
      • longType

        public IType longType()
        Retrieves the IType for Long.
        Returns:
        The external form of the Long class
      • longType

        public IType longType​(IType type)
        Converts the given IType, if it's the primitive long, into the Long type.
        Parameters:
        type - The IType to possibly convert
        Returns:
        The given type if it's not the primitive long or the IType for the class Long
      • mapType

        public IType mapType()
        Retrieves the IType for Map.
        Returns:
        The external form of the Map class
      • numberType

        public IType numberType()
        Retrieves the IType for Number.
        Returns:
        The external form of the Number class
      • objectType

        public IType objectType()
        Retrieves the IType for Object.
        Returns:
        The external form of the Object class
      • primitiveBoolean

        public IType primitiveBoolean()
        Retrieves the IType for the primitive boolean.
        Returns:
        The external form of the primitive boolean
      • primitiveByte

        public IType primitiveByte()
        Retrieves the IType for the primitive byte.
        Returns:
        The external form of the primitive byte
      • primitiveChar

        public IType primitiveChar()
        Retrieves the IType for the primitive char.
        Returns:
        The external form of the primitive char
      • primitiveDouble

        public IType primitiveDouble()
        Retrieves the IType for the primitive double.
        Returns:
        The external form of the primitive double
      • primitiveFloat

        public IType primitiveFloat()
        Retrieves the IType for the primitive float.
        Returns:
        The external form of the primitive float
      • primitiveInteger

        public IType primitiveInteger()
        Retrieves the IType for the primitive int.
        Returns:
        The external form of the primitive int
      • primitiveLong

        public IType primitiveLong()
        Retrieves the IType for the primitive long.
        Returns:
        The external form of the primitive long
      • primitiveShort

        public IType primitiveShort()
        Retrieves the IType for the primitive short.
        Returns:
        The external form of the primitive short
      • shortType

        public IType shortType()
        Retrieves the IType for Short.
        Returns:
        The external form of the Short class
      • stringType

        public IType stringType()
        Retrieves the IType for String.
        Returns:
        The external form of the String class
      • timestampType

        public IType timestampType()
        Retrieves the IType for Timestamp.
        Returns:
        The external form of the Timestamp class
      • toBooleanType

        public IType toBooleanType​(IType type)
        Converts the given IType, if it's the primitive boolean, into the Boolean type.
        Parameters:
        type - The IType to possibly convert
        Returns:
        The given type if it's not the primitive boolean or the IType for the class Boolean
      • toByteType

        public IType toByteType​(IType type)
        Converts the given IType, if it's the primitive byte, into the Byte type.
        Parameters:
        type - The IType to possibly convert
        Returns:
        The given type if it's not the primitive byte or the IType for the class Byte
      • toDoubleType

        public IType toDoubleType​(IType type)
        Converts the given IType, if it's the primitive double, into the Double type.
        Parameters:
        type - The IType to possibly convert
        Returns:
        The given type if it's not the primitive double or the IType for the class Double
      • toFloatType

        public IType toFloatType​(IType type)
        Converts the given IType, if it's the primitive float, into the Float type.
        Parameters:
        type - The IType to possibly convert
        Returns:
        The given type if it's not the primitive float or the IType for the class Float
      • toIntegerType

        public IType toIntegerType​(IType type)
        Converts the given IType, if it's the primitive int, into the Integer type.
        Parameters:
        type - The IType to possibly convert
        Returns:
        The given type if it's not the primitive int or the IType for the class Integer
      • toShortType

        public IType toShortType​(IType type)
        Converts the given IType, if it's the primitive short, into the Short type.
        Parameters:
        type - The IType to possibly convert
        Returns:
        The given type if it's not the primitive short or the IType for the class Short
      • unknownType

        public IType unknownType()
        Retrieves the IType that represents an unknown type.
        Returns:
        The external form of an unknown type