Class PropertyTypeName
- java.lang.Object
-
- org.gcube.informationsystem.types.PropertyTypeName
-
public class PropertyTypeName extends Object
Represents the type name of a property, including its base type and any generic parameters.- Author:
- Luca Frosini (ISTI - CNR)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPropertyTypeName.BaseTypeThe fundamental data types for properties.static classPropertyTypeName.BaseTypeGroupGroups of base types.
-
Field Summary
Fields Modifier and Type Field Description protected static Map<Class<?>,PropertyTypeName.BaseType>BASE_PROPERTY_TYPES_BY_CLASSA map of base types, keyed by class.protected PropertyTypeName.BaseTypebaseTypeThe base type.protected Class<?>clzThe class of the property.protected PropertyTypeName.BaseTypegenericBaseTypeThe generic base type.protected StringgenericClassNameThe generic class name.protected booleangenericTypeA flag indicating whether the type is generic.protected static Map<Class<?>,String>REGEX_BY_CLASS_MAPPED_AS_STRINGA map of regex patterns for string representations of classes.protected static Map<String,String>REGEX_BY_CLASS_MAPPED_AS_STRING_BY_CLASS_NAMEA map of regex patterns for string representations of classes, keyed by class name.static StringURI_REGEXA regex for validating URIs.static StringURL_REGEXA regex for validating URLs.static StringUUID_REGEXA regex for validating UUIDs.
-
Constructor Summary
Constructors Constructor Description PropertyTypeName(Class<?> clz)Constructs aPropertyTypeNamefrom aClass.PropertyTypeName(Method method)Constructs aPropertyTypeNamefrom aMethod's return type.PropertyTypeName(String type)Constructs aPropertyTypeNamefrom a string representation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)PropertyTypeName.BaseTypegetBaseType()Returns the base type of this property.static PropertyTypeName.BaseTypegetBaseTypeByClass(Class<?> clazz)Determines the correspondingPropertyTypeName.BaseTypefor a given class.PropertyTypeName.BaseTypegetGenericBaseType()Returns the generic base type of this property, if applicable.StringgetGenericClassName()Returns the simple name of the generic class of this property, if applicable.static StringgetRegexByClass(Class<?> clz)Returns a regular expression for validating the string representation of a given class.static StringgetRegexByClassname(String className)Returns a regular expression for validating the string representation of a given class name.StringgetType()Returns the string representation of this type name.inthashCode()booleanisGenericType()Checks if this property type is generic.voidsetType(String type)Sets the type from a string representation.StringtoString()
-
-
-
Field Detail
-
BASE_PROPERTY_TYPES_BY_CLASS
protected static final Map<Class<?>,PropertyTypeName.BaseType> BASE_PROPERTY_TYPES_BY_CLASS
A map of base types, keyed by class.
-
REGEX_BY_CLASS_MAPPED_AS_STRING
protected static final Map<Class<?>,String> REGEX_BY_CLASS_MAPPED_AS_STRING
A map of regex patterns for string representations of classes.
-
REGEX_BY_CLASS_MAPPED_AS_STRING_BY_CLASS_NAME
protected static final Map<String,String> REGEX_BY_CLASS_MAPPED_AS_STRING_BY_CLASS_NAME
A map of regex patterns for string representations of classes, keyed by class name.
-
URI_REGEX
public static final String URI_REGEX
A regex for validating URIs.
-
URL_REGEX
public static final String URL_REGEX
A regex for validating URLs.
-
UUID_REGEX
public static final String UUID_REGEX
A regex for validating UUIDs.- See Also:
- Constant Field Values
-
baseType
protected PropertyTypeName.BaseType baseType
The base type.
-
genericType
protected boolean genericType
A flag indicating whether the type is generic.
-
genericBaseType
protected PropertyTypeName.BaseType genericBaseType
The generic base type.
-
genericClassName
protected String genericClassName
The generic class name.
-
clz
protected Class<?> clz
The class of the property.
-
-
Constructor Detail
-
PropertyTypeName
public PropertyTypeName(String type)
Constructs aPropertyTypeNamefrom a string representation.- Parameters:
type- The string representation of the type (e.g., "String", "List<Integer>").
-
PropertyTypeName
public PropertyTypeName(Class<?> clz)
Constructs aPropertyTypeNamefrom aClass.- Parameters:
clz- The class of the property.
-
-
Method Detail
-
getRegexByClass
public static String getRegexByClass(Class<?> clz)
Returns a regular expression for validating the string representation of a given class.- Parameters:
clz- The class.- Returns:
- The validation regex, or
nullif none is defined.
-
getRegexByClassname
public static String getRegexByClassname(String className)
Returns a regular expression for validating the string representation of a given class name.- Parameters:
className- The simple name of the class.- Returns:
- The validation regex, or
nullif none is defined.
-
getBaseTypeByClass
public static PropertyTypeName.BaseType getBaseTypeByClass(Class<?> clazz)
Determines the correspondingPropertyTypeName.BaseTypefor a given class.- Parameters:
clazz- The class to check.- Returns:
- The corresponding
BaseType, ornull.
-
setType
public void setType(String type)
Sets the type from a string representation.- Parameters:
type- The string representation of the type.
-
getType
public String getType()
Returns the string representation of this type name.- Returns:
- The type name as a string.
-
getBaseType
public PropertyTypeName.BaseType getBaseType()
Returns the base type of this property.- Returns:
- The base type.
-
isGenericType
public boolean isGenericType()
Checks if this property type is generic.- Returns:
trueif the type is generic.
-
getGenericBaseType
public PropertyTypeName.BaseType getGenericBaseType()
Returns the generic base type of this property, if applicable.- Returns:
- The generic base type, or
null.
-
getGenericClassName
public String getGenericClassName()
Returns the simple name of the generic class of this property, if applicable.- Returns:
- The generic class name, or
null.
-
-