Package com.arcadedb.schema
Enum Type
- java.lang.Object
-
- java.lang.Enum<Type>
-
- com.arcadedb.schema.Type
-
- All Implemented Interfaces:
Serializable
,Comparable<Type>
public enum Type extends Enum<Type>
Generic representation of a type.
allowAssignmentFrom accepts any class, but Array.class means that the type accepts generic Arrays.- Author:
- Luca Garulli (l.garulli--(at)--gmail.com)
-
-
Field Summary
Fields Modifier and Type Field Description protected Class<?>[]
allowAssignmentFrom
protected byte
binaryType
protected Set<Type>
castable
protected int
id
protected Class<?>
javaDefaultType
protected String
name
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description double
asDouble(Object iValue)
Convert the input object to a Double.float
asFloat(Object iValue)
Convert the input object to a Float.int
asInt(Object iValue)
Convert the input object to an integer.long
asLong(Object iValue)
Convert the input object to a long.String
asString(Object iValue)
Deprecated.static Number[]
castComparableNumber(Number context, Number max)
static Object
convert(Database database, Object iValue, Class<?> iTargetClass)
Convert types based on the iTargetClass parameter.static Number
decrement(Number a, Number b)
byte
getBinaryType()
static Type
getById(byte iId)
Return the type by ID.Set<Type>
getCastable()
Class<?>
getDefaultJavaType()
int
getId()
Get the identifier of the type.Class<?>[]
getJavaTypes()
Deprecated.static Type
getTypeByClass(Class<?> iClass)
Return the correspondent type by checking the "assignability" of the class received as parameter.static Type
getTypeByName(String name)
static Type
getTypeByValue(Object value)
static Number
increment(Number a, Number b)
boolean
isEmbedded()
boolean
isLink()
boolean
isMultiValue()
static boolean
isSimpleType(Object iObject)
Object
newInstance(Object value)
static void
validateValue(Object value)
static Type
valueOf(String name)
Returns the enum constant of this type with the specified name.static Type[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
BOOLEAN
public static final Type BOOLEAN
-
INTEGER
public static final Type INTEGER
-
SHORT
public static final Type SHORT
-
LONG
public static final Type LONG
-
FLOAT
public static final Type FLOAT
-
DOUBLE
public static final Type DOUBLE
-
DATETIME
public static final Type DATETIME
-
STRING
public static final Type STRING
-
BINARY
public static final Type BINARY
-
LIST
public static final Type LIST
-
MAP
public static final Type MAP
-
LINK
public static final Type LINK
-
BYTE
public static final Type BYTE
-
DATE
public static final Type DATE
-
DECIMAL
public static final Type DECIMAL
-
EMBEDDED
public static final Type EMBEDDED
-
-
Method Detail
-
values
public static 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 (Type c : 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 Type valueOf(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:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
getById
public static Type getById(byte iId)
Return the type by ID.- Parameters:
iId
- The id to search- Returns:
- The type if any, otherwise null
-
validateValue
public static void validateValue(Object value)
-
getId
public int getId()
Get the identifier of the type. use this instead ofEnum.ordinal()
for guarantee a cross code version identifier.- Returns:
- the identifier of the type.
-
getTypeByClass
public static Type getTypeByClass(Class<?> iClass)
Return the correspondent type by checking the "assignability" of the class received as parameter.- Parameters:
iClass
- Class to check- Returns:
- OType instance if found, otherwise null
-
isSimpleType
public static boolean isSimpleType(Object iObject)
-
convert
public static Object convert(Database database, Object iValue, Class<?> iTargetClass)
Convert types based on the iTargetClass parameter.- Parameters:
iValue
- Value to convertiTargetClass
- Expected class- Returns:
- The converted value or the original if no conversion was applied
-
asInt
public int asInt(Object iValue)
Convert the input object to an integer.- Parameters:
iValue
- Any type supported- Returns:
- The integer value if the conversion succeed, otherwise the IllegalArgumentException exception
-
asLong
public long asLong(Object iValue)
Convert the input object to a long.- Parameters:
iValue
- Any type supported- Returns:
- The long value if the conversion succeed, otherwise the IllegalArgumentException exception
-
asFloat
public float asFloat(Object iValue)
Convert the input object to a Float.- Parameters:
iValue
- Any type supported- Returns:
- The float value if the conversion succeed, otherwise the IllegalArgumentException exception
-
asDouble
public double asDouble(Object iValue)
Convert the input object to a Double.- Parameters:
iValue
- Any type supported- Returns:
- The double value if the conversion succeed, otherwise the IllegalArgumentException exception
-
getBinaryType
public byte getBinaryType()
-
asString
@Deprecated public String asString(Object iValue)
Deprecated.Convert the input object to a string.- Parameters:
iValue
- Any type supported- Returns:
- The string if the conversion succeed, otherwise the IllegalArgumentException exception
-
isMultiValue
public boolean isMultiValue()
-
isLink
public boolean isLink()
-
isEmbedded
public boolean isEmbedded()
-
getDefaultJavaType
public Class<?> getDefaultJavaType()
-
getJavaTypes
@Deprecated public Class<?>[] getJavaTypes()
Deprecated.
-
-