Package com.collibra.dgc.core.api.model.instance.attribute

# Interface Attribute

All Superinterfaces:
  `Entity`, `Resource`, `Serializable`

All Known Subinterfaces:
  `BooleanAttribute`, `DateAttribute`, `MultiValueListAttribute`, `NumericAttribute`, `ScriptAttribute`, `SingleValueListAttribute`, `StringAttribute`

public interface Attribute extends Resource
Abstract super class for attributes

- ## Method Summary

  Modifier and Type
  Method
  Description
  `NamedResourceReference`
  `getAsset()`
  Returns the asset this attribute belongs to.
  `String`
  `getAttributeDiscriminator()`
  Returns the discriminator of this Attribute, which indicates the type.
  `NamedResourceReference`
  `getType()`
  Returns the attribute type for this attribute.
  `Object`
  `getValue()`
  Returns the value of this attribute.
  `<T> T`
  `getValueAs(Class<T> clazz)`
  Returns the value of this attribute casted to the class required by the parameter.
  `String`
  `getValueAsString()`
  Returns the value of this attribute represented as a `String`.

  ### Methods inherited from interface Entity

  `getId, setId`

  ### Methods inherited from interface Resource

  `getCreatedBy, getCreatedOn, getLastModifiedBy, getLastModifiedOn, getResourceType, isSystem`

- ## Method Details

  - ### getType

    NamedResourceReference getType()
    Returns the attribute type for this attribute.
    Returns:
      the attribute type for this attribute

  - ### getAsset

    NamedResourceReference getAsset()
    Returns the asset this attribute belongs to.
    Returns:
      the asset this attribute belongs to

  - ### getValue

    Object getValue()
    Returns the value of this attribute. Class of the returned object depends on the type of the attribute. Following list presents class of the value depending on the kind of the attribute

    - kind: `NumericAttribute` -> value Class: `Double`
    - kind: `ScriptAttribute` -> value Class: `String`
    - kind: `SingleValueListAttribute` -> value Class: `String`
    - kind: `DateAttribute` -> value class: `Long`
    - kind: `StringAttribute` -> value class: `String`
    - kind: `BooleanAttribute` -> value class: `Boolean`
    - kind: `MultiValueListAttribute` -> value class: `List` of `String`

    When retrieving attributes of a known kind it's safe to cast the value to the required class or use `getValueAs(Class)` method passing the correct class of the attribute value. To dynamically check the kind of attribute it is possible to i.e.:

         if(attribute instanceof NumericAttribute) {
              Double value = attribute.getValueAs(Double.class);
         }

    or

         if(attribute.getType().getResourceType() == NumericAttribute) {
              Double value = attribute.getValueAs(Double.class);
         }

    Returns:
      the value of this attribute

  - ### getValueAs

    <T> T getValueAs(Class<T> clazz)
    Returns the value of this attribute casted to the class required by the parameter. Class of the returned object depends on the type of the attribute. Following list presents class of the value depending on the kind of the attribute

    - kind: `NumericAttribute` -> value Class: `Double`
    - kind: `ScriptAttribute` -> value Class: `String`
    - kind: `SingleValueListAttribute` -> value Class: `String`
    - kind: `DateAttribute` -> value class: `Long`
    - kind: `StringAttribute` -> value class: `String`
    - kind: `BooleanAttribute` -> value class: `Boolean`
    - kind: `MultiValueListAttribute` -> value class: `List` of `String`

    When retrieving attributes of a known kind it's safe to cast the value to the required class or use `getValueAs(Class)` method passing the correct class of the attribute value. To dynamically check the kind of attribute it is possible to i.e.:

         if(attribute instanceof NumericAttribute) {
              Double value = attribute.getValueAs(Double.class);
         }

    or

         if(attribute.getType().getResourceType() == NumericAttribute) {
              Double value = attribute.getValueAs(Double.class);
         }

    Returns:
      the value of this attribute

  - ### getValueAsString

    String getValueAsString()
    Returns the value of this attribute represented as a `String`. Values of `MultiValueListAttribute` are represented as a ';' separated `String`
    Returns:
      the value of this attribute as a `String`

  - ### getAttributeDiscriminator

    String getAttributeDiscriminator()
    Returns the discriminator of this Attribute, which indicates the type. The value can be one of : NumericAttribute, ScriptAttribute, SingleValueListAttribute, DateAttribute, StringAttribute, BooleanAttribute or MultiValueListAttribute.
    Returns:
      the attribute discriminator