Class PropertyTypeName
java.lang.Object
org.gcube.informationsystem.types.PropertyTypeName
Represents the type name of a property, including its base type and any
generic parameters.
- Author:
- Luca Frosini (ISTI - CNR)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe fundamental data types for properties.static enumGroups of base types.static enumString-overlay semantic types: JSON string values (PropertyTypeName.BaseType.STRINGat the wire level) that carry extra, class-specific validation semantics -- a fixed validation regex and a documented meaning. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Map<Class<?>,PropertyTypeName.BaseType> A map of base types, keyed by class.protected PropertyTypeName.BaseTypeThe base type.protected Class<?>The class of the property.static final StringConstraint on non-collection base types: onlyPropertyTypeName.BaseType.LIST/PropertyTypeName.BaseType.SET/PropertyTypeName.BaseType.MAPmay declare a generic type.protected PropertyTypeName.BaseTypeThe generic base type.static final StringConstraint onPropertyTypeName.BaseType.MAP: its key must always bePropertyTypeName.BaseType.STRING.static final StringConstraint onPropertyTypeName.BaseType.LIST/PropertyTypeName.BaseType.SET: the generic type must be declared explicitly (e.g.protected StringThe name of the referenced Property-family class, if any --nullfor flat scalars and for collections of a flat scalar.static final StringConstraint onPropertyTypeName.BaseType.LIST/PropertyTypeName.BaseType.SET/PropertyTypeName.BaseType.MAP: their generic/value type must be a non-collection base type -- collections cannot be nested.protected static final Map<Class<?>,PropertyTypeName.SemanticType> A map of semantic types, keyed by class.protected static final Map<String,PropertyTypeName.SemanticType> A map of semantic types, keyed by class simple name.protected booleanWhether this type is structured -- a Property-family class reference or a List/Set/Map, as opposed to a flat scalar (String, Integer, Boolean, Date, ...). -
Constructor Summary
ConstructorsConstructorDescriptionPropertyTypeName(Class<?> clz) Constructs aPropertyTypeNamefrom aClass.PropertyTypeName(Method method) Constructs aPropertyTypeNamefrom aMethod's return type.PropertyTypeName(String type) Constructs aPropertyTypeNamefrom a string representation. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the base type of this property.static PropertyTypeName.BaseTypegetBaseTypeByClass(Class<?> clazz) Determines the correspondingPropertyTypeName.BaseTypefor a given class.Returns the generic base type of this property, if applicable.Returns the simple name of the referenced Property-family class, if any -- direct or as a collection's element type.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.getType()Returns the string representation of this type name.inthashCode()booleanChecks whether this property type is structured: a direct Property-family class reference (e.g.voidSets the type from a string representation.toString()
-
Field Details
-
BASE_PROPERTY_TYPES_BY_CLASS
A map of base types, keyed by class. -
SEMANTIC_TYPES_BY_CLASS
A map of semantic types, keyed by class. -
SEMANTIC_TYPES_BY_CLASS_NAME
A map of semantic types, keyed by class simple name. -
baseType
The base type. -
structuredType
protected boolean structuredTypeWhether this type is structured -- a Property-family class reference or a List/Set/Map, as opposed to a flat scalar (String, Integer, Boolean, Date, ...). Does not by itself guaranteenamedTypeNameis set: a scalar-typed collection (e.g.List<Integer>) is structured too, but has no named class to report. -
genericBaseType
The generic base type. -
namedTypeName
The name of the referenced Property-family class, if any --nullfor flat scalars and for collections of a flat scalar. -
clz
The class of the property. -
MISSING_GENERIC_TYPE_MESSAGE
Constraint onPropertyTypeName.BaseType.LIST/PropertyTypeName.BaseType.SET: the generic type must be declared explicitly (e.g.Set<Property>, not a bareSet).- See Also:
-
GENERIC_NOT_ALLOWED_MESSAGE
Constraint on non-collection base types: onlyPropertyTypeName.BaseType.LIST/PropertyTypeName.BaseType.SET/PropertyTypeName.BaseType.MAPmay declare a generic type.- See Also:
-
MAP_KEY_MUST_BE_STRING_MESSAGE
Constraint onPropertyTypeName.BaseType.MAP: its key must always bePropertyTypeName.BaseType.STRING.- See Also:
-
NESTED_COLLECTION_NOT_ALLOWED_MESSAGE_FORMAT
Constraint onPropertyTypeName.BaseType.LIST/PropertyTypeName.BaseType.SET/PropertyTypeName.BaseType.MAP: their generic/value type must be a non-collection base type -- collections cannot be nested. AString.formattemplate, taking the offending base type's name.- See Also:
-
-
Constructor Details
-
PropertyTypeName
Constructs aPropertyTypeNamefrom a string representation.- Parameters:
type- The string representation of the type (e.g., "String", "List<Integer>").
-
PropertyTypeName
Constructs aPropertyTypeNamefrom aClass.- Parameters:
clz- The class of the property.
-
PropertyTypeName
Constructs aPropertyTypeNamefrom aMethod's return type.- Parameters:
method- The method.
-
-
Method Details
-
getRegexByClass
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
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
Determines the correspondingPropertyTypeName.BaseTypefor a given class.- Parameters:
clazz- The class to check.- Returns:
- The corresponding
BaseType, ornull.
-
setType
Sets the type from a string representation.- Parameters:
type- The string representation of the type.
-
getType
Returns the string representation of this type name.- Returns:
- The type name as a string.
-
toString
-
getBaseType
Returns the base type of this property.- Returns:
- The base type.
-
isStructuredType
public boolean isStructuredType()Checks whether this property type is structured: a direct Property-family class reference (e.g.EnumStringProperty), or aList/Set/Map-- as opposed to a flat scalar likeStringorInteger. A structured collection of scalars (e.g.List<Integer>) is stilltruehere even though it has no named class to report -- checkgetNamedTypeName()for that.- Returns:
trueif this type is a Property-family reference or a collection.
-
getGenericBaseType
Returns the generic base type of this property, if applicable.- Returns:
- The generic base type, or
null.
-
getNamedTypeName
Returns the simple name of the referenced Property-family class, if any -- direct or as a collection's element type.nullfor flat scalars and for collections of a flat scalar, even whenisStructuredType()istrue.- Returns:
- The referenced class name, or
null.
-
hashCode
public int hashCode() -
equals
-