Class DefaultTypeAttributeDescriptor

  • All Implemented Interfaces:
    TypeAttributeDescriptor

    public class DefaultTypeAttributeDescriptor
    extends java.lang.Object
    implements TypeAttributeDescriptor

    This implementation is effectively immutable and therefore is thread safe.

    Reuse this class through composition, not inheritance.

    • Method Detail

      • getAttributeName

        public java.lang.String getAttributeName()
        Description copied from interface: TypeAttributeDescriptor
        Gets name of the attribute described by this descriptor.
        Specified by:
        getAttributeName in interface TypeAttributeDescriptor
        Returns:
        name of the attribute as it was defined for the integration object.
      • getQualifier

        public java.lang.String getQualifier()
        Description copied from interface: TypeAttributeDescriptor
        Gets name of this attribute in the platform type system.
        Specified by:
        getQualifier in interface TypeAttributeDescriptor
        Returns:
        name of this attribute in the type system.
      • isCollection

        public boolean isCollection()
        Determines whether this attribute contains a single value or multiple values (a collection of values).
        Specified by:
        isCollection in interface TypeAttributeDescriptor
        Returns:
        true, if the underlying AttributeDescriptorModel represents a collection or a one-to-many relationship or, in other words, if the corresponding accessor in the generated item has a Collection return type, e.g.
             public class Parent {
                 ...
                 Collection<Child> Parent.getChildren() {...}
                 ...
             }
         
        From the implementation standpoint it does not matter how that collection is modeled by CollectionTypeModel or RelationDescriptorModel - as long as it's a collection or one of its subtypes returned this method returns true. Otherwise, it returns false
      • getAttributeType

        public TypeDescriptor getAttributeType()
        Retrieves type of this attribute value(s).

        This implementation derives the correct TypeModel depending on whether the attribute represents a collection, a relation or a simple attribute and then creates TypeDescriptor, which is cached in this class.

        Specified by:
        getAttributeType in interface TypeAttributeDescriptor
        Returns:
        type of this attribute value, which may be a primitive type or a complex type referring an item in the type system; or a type of the referenced element(s) in case, if this attributes contains a collection of values or represents a one-to-one, one-to-many or many-to-many relationship.
        See Also:
        TypeAttributeDescriptor.isCollection()
      • reverse

        public java.util.Optional<TypeAttributeDescriptor> reverse()
        Description copied from interface: TypeAttributeDescriptor

        Reverses the relation described by this attribute descriptor and retrieves an attribute descriptor defined in the TypeAttributeDescriptor.getAttributeType() type descriptor with TypeAttributeDescriptor.getTypeDescriptor() attribute type.

        For example, type Parent has attribute children that refers a collection of type Child; and type Child has an attribute parent referring back to Parent type. Then attribute descriptor for parent attribute is reverse for children attribute descriptor.

        Another example, type Organization has attribute addresses that refers a collection of type Address; but type Address does not refer back to type Organization. In this case there is no reverse attribute for addresses attribute descriptor.

        Specified by:
        reverse in interface TypeAttributeDescriptor
        Returns:
        an optional containing a descriptor for the attribute in type returned by TypeAttributeDescriptor.getAttributeType(), which refers back to the type retrieved by calling TypeAttributeDescriptor.getTypeDescriptor() on this attribute descriptor; or an empty optional that attribute type of this descriptor does not refer back to the type containing this attribute descriptor.
      • isNullable

        public boolean isNullable()
        Description copied from interface: TypeAttributeDescriptor
        Determines whether the attribute represented by this descriptor can take null values.
        Specified by:
        isNullable in interface TypeAttributeDescriptor
        Returns:
        true, if the attribute can take null values; false, if the attribute value is required.
      • isPartOf

        public boolean isPartOf()
        Description copied from interface: TypeAttributeDescriptor
        Determines whether the item referenced by this attribute should be a part of the attribute's item model or not. This defines in particular whether the nested referenced item will be created whenever the "container" item is persisted (part of) or it can and should exist and persist independently (not a part of). For example, a Car has an attribute engine, which refers item Engine. If the business model is interested in cars only and does not care about engines outside of the car model, then the attribute should be defined with partOf == true. If the engine has independent existence, e.g. engine can be sold without a car, then the attribute should defined with partOf == false.

        In other words, this attribute descriptor defines a relation between an owner and the owned item. Thus in the example above Engine is owned by Car as it does not have independent existence in the model.

        Specified by:
        isPartOf in interface TypeAttributeDescriptor
        Returns:
        true, if the item referenced by this attribute descriptor is an integral part of its owner model.
        See Also:
        TypeAttributeDescriptor.isAutoCreate()
      • isAutoCreate

        public boolean isAutoCreate()
        Determines whether the item referenced by this attribute should be persisted when the item with this attribute is persisted. Unlike TypeAttributeDescriptor.isPartOf() this method does not require the referenced item to be an integral part of the owner item. The referenced item may have its independent existence in the domain model and yet it will be persisted together with the item holding an attribute described by this descriptor.
        Specified by:
        isAutoCreate in interface TypeAttributeDescriptor
        Returns:
        true, if the attribute is defined with partOf == true in the type system or the corresponding IntegrationObjectItemAttributeModel has autoCreate == true; false, otherwise.
        See Also:
        TypeAttributeDescriptor.isPartOf()
      • isLocalized

        public boolean isLocalized()
        Description copied from interface: TypeAttributeDescriptor
        Determines whether the value of this descriptor can be localized. This method may need to be used with TypeAttributeDescriptor.isMap() to determine whether the attribute supports multiple locale specific values. Some attributes may be localized but do not support multi-locale values. For example, a simple Numeric or Boolean attribute can be declared as localized.
        Specified by:
        isLocalized in interface TypeAttributeDescriptor
        Returns:
        true if localized, else false
      • isPrimitive

        public boolean isPrimitive()
        Description copied from interface: TypeAttributeDescriptor
        Determines whether the value of this descriptor is a primitive type
        Specified by:
        isPrimitive in interface TypeAttributeDescriptor
        Returns:
        true if it's a primitive type, else false
      • isMap

        public boolean isMap()
        Description copied from interface: TypeAttributeDescriptor
        Determines whether the attribute is referring to a map of values. Typically used to determiine in conjunction with TypeAttributeDescriptor.isLocalized() to determine whether the attribute can hold multiple locale specific values. However, it can be used by itself.
        Specified by:
        isMap in interface TypeAttributeDescriptor
        Returns:
        true, if the attribute refers to a map; false otherwise.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object