Class TLcdDataProperty

java.lang.Object
com.luciad.datamodel.TLcdDataProperty
All Implemented Interfaces:
ILcdAnnotatedElement

public final class TLcdDataProperty extends Object implements ILcdAnnotatedElement

Represents a property of a type. A property always belongs to a certain type (called its declaring type) and also has a certain type (called its type). Many-valued properties have a CollectionType that defines what kind of collection (list, set or map) is represented. The combination of the property's type and its CollectionType constrain the values that a property can have for a data object as follows:

  • Values for single-valued properties are instances of the type returned by getType().
  • Values for many-valued properties are determined by the property's CollectionType.
    • LIST: values are instances of java.util.List. The elements of the list are instances of the type returned by getType().
    • SET: values are instances of java.util.Set. The elements of the set are instances of the type returned by getType().
    • MAP: values are instances of java.util.Map. The values of the map are instances of the type returned by getType(). The keys are instances of the type returned by getMapKeyType().

Properties can be defined by first creating a TLcdDataModelBuilder, then defining types within that data model using TLcdDataTypeBuilder, and finally defining properties on these types using TLcdDataPropertyBuilder. See TLcdDataModelBuilder for a brief example.

Existing properties can be retrieved via the TLcdDataType on which they are defined.

Instances of this class are thread safe. Once an instance has been created, there is no public API to modify it. The only exception is the annotations and these are thread safe.

Since:
10.0
See Also:
  • Method Details

    • getDeclaringType

      public TLcdDataType getDeclaringType()
      Returns the type that declares this property. The condition getDeclaringType().getDeclaredProperties().contains( this ) always holds true.
      Returns:
      the type on which this property is declared
    • hasDefaultValue

      public boolean hasDefaultValue()
      Determines if this property has a default value or not.
      Returns:
      true if this property has a default value; false otherwise
    • getDefaultValue

      public Object getDefaultValue()
      Returns the default value for this property. In case the property has no default value, null is returned. null may also be the default value for this property. hasDefaultValue() can be used to disambiguate between null as default value and null as indication of no default value.
      Returns:
      the default value for this property
      See Also:
    • getIndex

      public int getIndex()

      Returns the index of this property in the list of properties of its declaring type. Expressed in pseudo-code, this would look like getDeclaringType().getProperties().indexOf( this ).

      This method is provided to allow simple but efficient implementations of the ILcdDataObject interface.

      Returns:
      the index of this property in this property's declaring type's properties
    • getName

      public String getName()
      Returns the name of this property. This name may differ from the property name as it was defined in the source data, because it can contain only alphanumeric characters and underscores and may have been sanitized. When this is the case, the original unaltered property name can still be retrieved through getSourceName().
      Returns:
      the name of this property
      See Also:
    • getSourceName

      public String getSourceName()
      Returns the original name of this property, as it was defined in the source data. This may differ from the actual name of this property within the TLcdDataType, because that name can contain only alphanumeric characters and underscores and may have been sanitized.
      Returns:
      the original name of this property, as it was defined in the source data.
      Since:
      2024.0
      See Also:
    • getType

      public TLcdDataType getType()
      Returns the type of this property.
      Returns:
      the type of this property
    • isCollection

      public boolean isCollection()
      Determines if the property is many-valued. This method is equivalent to getCollectionType() != null.

      Note that values for many-valued properties not necessarily implement java.util.Collection as Map is not an extension of Collection.

      Returns:
      if the property is many-valued.
      See Also:
    • getCollectionType

      public TLcdDataProperty.CollectionType getCollectionType()
      Returns the collection type of this property. In case the property is single-valued, null is returned. The collection type defines which values are valid for this property.
      • LIST: valid values for this property implement java.util.List
      • SET: valid values for this property implement java.util.Set
      • MAP: valid values for this property implement java.util.Map
      Returns:
      the collection type for this property
    • getMapKeyType

      public TLcdDataType getMapKeyType()
      For properties of which the collection type is MAP, returns the type of the keys. Otherwise returns null. The values in the map are of the type returned by getType().
      Returns:
      the type of the keys for map properties
    • isNullable

      public boolean isNullable()
      Determines if null values are acceptable for this property. In case of collection properties, determines if the collection can be empty.
      Returns:
      if null values or empty collections are acceptable
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getAnnotation

      public <T extends ILcdAnnotation> T getAnnotation(Class<T> aAnnotationType)
      Description copied from interface: ILcdAnnotatedElement

      Returns the element's annotation for the specified class if such an annotation is present, else null.

      Note that the exact annotation class needs to be passed as parameter. In other words, in case the element is only annotated with instances of subclasses of the given annotation class, null is returned.

      Specified by:
      getAnnotation in interface ILcdAnnotatedElement
      Parameters:
      aAnnotationType - - the Class object corresponding to the annotation type
      Returns:
      this element's annotation for the specified annotation class if present on this element, else null
    • isAnnotationPresent

      public boolean isAnnotationPresent(Class<? extends ILcdAnnotation> aAnnotationType)
      Description copied from interface: ILcdAnnotatedElement

      Returns true if an annotation for the specified class is present on this element, else false. This method is designed primarily for convenient access to marker annotations.

      Note that the exact annotation class needs to be passed as parameter. In other words, in case the element is only annotated with instances of subclasses of the given annotation class, false is returned.

      Specified by:
      isAnnotationPresent in interface ILcdAnnotatedElement
      Parameters:
      aAnnotationType - the Class object corresponding to the annotation class
      Returns:
      true if an annotation for the specified annotation class is present on this element, else false
    • getAnnotations

      public Collection<ILcdAnnotation> getAnnotations()
      Description copied from interface: ILcdAnnotatedElement
      Returns all annotations present on this element as an unmodifiable collection.
      Specified by:
      getAnnotations in interface ILcdAnnotatedElement
      Returns:
      all annotations present on this element
    • addAnnotation

      public <T extends ILcdAnnotation> T addAnnotation(ILcdAnnotation aAnnotation)
      Description copied from interface: ILcdAnnotatedElement
      Adds the given annotation to this element.
      Specified by:
      addAnnotation in interface ILcdAnnotatedElement
      Parameters:
      aAnnotation - the annotation to add
      Returns:
      the previous annotation of the same class as the given annotation associated with this element, or null if there was no annotation for that class.
    • removeAnnotation

      public <T extends ILcdAnnotation> T removeAnnotation(Class<T> aAnnotationClass)
      Description copied from interface: ILcdAnnotatedElement

      Removes the annotation of the given class from this element.

      Note that the exact annotation class needs to be passed as parameter. In other words, in case the element is only annotated with instances of subclasses of the given annotation class, nothing is removed and null is returned.

      Specified by:
      removeAnnotation in interface ILcdAnnotatedElement
      Parameters:
      aAnnotationClass - the class of annotation to remove
      Returns:
      the annotation of the given class that was associated with this element, or null if there was no annotation for that class.
    • isContained

      public boolean isContained()
      Determines if this property represents composition (as opposed to mere aggregation). In other words, a data object has the lifetime responsibility for all the values of all properties that are contained.
      Returns:
      if the value of this property is contained in the owning instance
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getDisplayName

      public String getDisplayName()
      Returns a displayable name for this property, suitable for usage in user interfaces.
      Returns:
      a displayable name for the property.
      See Also: