Package com.iizix
Enum Value.Type
- java.lang.Object
- java.lang.Enum<Value.Type>
- com.iizix.Value.Type
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<Value.Type>
- Enclosing class:
- Value
public static enum Value.Type extends java.lang.Enum<Value.Type>
The enumeration of Types.
Enum Constant Summary
Enum Constants Enum Constant Description BigDecimal
The Data Type: BigDecimal.BigInteger
The Data Type: BigInteger.Binary
The Data Type: Binary as byte [].Boolean
The Data Type: T_Boolean as Boolean.Byte
The Data Type: Byte.Double
The Data Type: Double.Duration
The Data Type: java.time.Duration.Float
The Data Type: Float.Integer
The Data Type: Integer.KString
The Data Type: String value.LocalDate
The Data Type: java.time.LocalDate.LocalDateTime
The Data Type: java.time.LocalDateTime.LocalTime
The Data Type: java.time.LocalTime.Long
The Data Type: Long.MonthDay
The Data Type: java.time.MonthDay.OffsetDateTime
The Data Type: java.time.OffsetDateTime.OffsetTime
The Data Type: java.time.OffsetTime.Period
The Data Type: java.time.Period.Short
The Data Type: Short.String
The Data Type: String value.XMLDuration
The Data Type: javax.xml.datatype.Duration.XMLGregorianCalendar
The Data Type: XMLGregorianCalendar using ImmutableXMLGregorianCalendar value class.Year
The Data Type: java.time.Year.YearMonth
The Data Type: java.time.YearMonth.ZonedDateTime
The Data Type: java.time.ZonedDateTime.
Field Summary
Fields Modifier and Type Field Description Value.Category
category
The category, null for value-specific category.Value
nullValue
The null value for the type.IValueObject<?>
valueObject
The interface that creates the default value.
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canConvertTo(Value.Type dest)
Returns if this value can be converted to another value type.Value
createDefault()
Creates a default value.Value
getDefaultValue(boolean isNullAllowed)
Gets a shared instance of anull
or defaultValue
of the specified type depending on theisNullAllowed
flag.int
getSQLType()
Gets the default SQL type for this Type.static Value.Type
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static Value.Type[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
Enum Constant Detail
String
public static final Value.Type String
The Data Type: String value.
KString
public static final Value.Type KString
The Data Type: String value.
Boolean
public static final Value.Type Boolean
The Data Type: T_Boolean as Boolean.
Byte
public static final Value.Type Byte
The Data Type: Byte.
Short
public static final Value.Type Short
The Data Type: Short.
Integer
public static final Value.Type Integer
The Data Type: Integer.
Long
public static final Value.Type Long
The Data Type: Long.
Float
public static final Value.Type Float
The Data Type: Float.
Double
public static final Value.Type Double
The Data Type: Double.
BigInteger
public static final Value.Type BigInteger
The Data Type: BigInteger.
BigDecimal
public static final Value.Type BigDecimal
The Data Type: BigDecimal.
LocalTime
public static final Value.Type LocalTime
The Data Type: java.time.LocalTime.
OffsetTime
public static final Value.Type OffsetTime
The Data Type: java.time.OffsetTime.
LocalDate
public static final Value.Type LocalDate
The Data Type: java.time.LocalDate.
MonthDay
public static final Value.Type MonthDay
The Data Type: java.time.MonthDay. No SQL mapping.
Year
public static final Value.Type Year
The Data Type: java.time.Year. No SQL mapping.
YearMonth
public static final Value.Type YearMonth
The Data Type: java.time.YearMonth. No SQL mapping.
LocalDateTime
public static final Value.Type LocalDateTime
The Data Type: java.time.LocalDateTime.
OffsetDateTime
public static final Value.Type OffsetDateTime
The Data Type: java.time.OffsetDateTime.
ZonedDateTime
public static final Value.Type ZonedDateTime
The Data Type: java.time.ZonedDateTime.
XMLGregorianCalendar
public static final Value.Type XMLGregorianCalendar
The Data Type: XMLGregorianCalendar using ImmutableXMLGregorianCalendar value class.
Duration
public static final Value.Type Duration
The Data Type: java.time.Duration. No SQL mapping.
Period
public static final Value.Type Period
The Data Type: java.time.Period. No SQL mapping.
XMLDuration
public static final Value.Type XMLDuration
The Data Type: javax.xml.datatype.Duration. No SQL mapping.
Binary
public static final Value.Type Binary
The Data Type: Binary as byte [].
Field Detail
nullValue
public final Value nullValue
The null value for the type.
valueObject
public final IValueObject<?> valueObject
The interface that creates the default value.
category
public final Value.Category category
The category, null for value-specific category.
Method Detail
values
public static Value.Type[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (Value.Type c : Value.Type.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
valueOf
public static Value.Type valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
createDefault
public Value createDefault()
Creates a default value.- Returns:
- A new default value.
getDefaultValue
public Value getDefaultValue(boolean isNullAllowed)
Gets a shared instance of anull
or defaultValue
of the specified type depending on theisNullAllowed
flag.- Parameters:
isNullAllowed
- Flag for null allowed.- Returns:
- The default or
null Value
of the value type. - Throws:
java.lang.IllegalArgumentException
- If type is not valid.
getSQLType
public int getSQLType()
Gets the default SQL type for this Type.- Returns:
- The SQL type, or
Types.JAVA_OBJECT
if no JDBC mapping is present.
canConvertTo
public boolean canConvertTo(Value.Type dest)
Returns if this value can be converted to another value type. Data or precision loss is accepted in this conversion, e.g. losing the decimal part (conversion from Float to Integer) or the time part for (converting date-time to date). Note that String and KString are set to be convertable to all types, but they may fail often, e.g. String converted to Date fails due to wrong format.- Parameters:
dest
- The destination type.- Returns:
- true if it is possible to convert, but if the value conversion succeeds or fails depends on the value itself (e.g. convert Integer 256 to Byte will fail).