Class 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)
    • Constructor Detail

      • PropertyTypeName

        public PropertyTypeName​(String type)
        Constructs a PropertyTypeName from a string representation.
        Parameters:
        type - The string representation of the type (e.g., "String", "List<Integer>").
      • PropertyTypeName

        public PropertyTypeName​(Class<?> clz)
        Constructs a PropertyTypeName from a Class.
        Parameters:
        clz - The class of the property.
      • PropertyTypeName

        public PropertyTypeName​(Method method)
        Constructs a PropertyTypeName from a Method's return type.
        Parameters:
        method - The method.
    • 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 null if 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 null if none is defined.
      • 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.
      • isStructuredType

        public boolean isStructuredType()
        Checks whether this property type is structured: a direct Property-family class reference (e.g. EnumStringProperty), or a List/Set/Map -- as opposed to a flat scalar like String or Integer. A structured collection of scalars (e.g. List<Integer>) is still true here even though it has no named class to report -- check getNamedTypeName() for that.
        Returns:
        true if this type is a Property-family reference or a collection.
      • getGenericBaseType

        public PropertyTypeName.BaseType getGenericBaseType()
        Returns the generic base type of this property, if applicable.
        Returns:
        The generic base type, or null.
      • getNamedTypeName

        public String getNamedTypeName()
        Returns the simple name of the referenced Property-family class, if any -- direct or as a collection's element type. null for flat scalars and for collections of a flat scalar, even when isStructuredType() is true.
        Returns:
        The referenced class name, or null.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object