Class ExtensibleData

java.lang.Object
org.gedcomx.common.ExtensibleData
All Implemented Interfaces:
HasTransientProperties, SupportsExtensionElements
Direct Known Subclasses:
Address, Attribution, Date, DisplayProperties, HypermediaEnabledData, NameForm, NamePart, OnlineAccount, PlaceDisplayProperties, PlaceReference

public abstract class ExtensibleData extends Object implements SupportsExtensionElements, HasTransientProperties
A set of data that supports extension elements.
Author:
Ryan Heaton
  • Field Details

    • extensionElements

      protected List<Object> extensionElements
    • transientProperties

      protected final Map<String,Object> transientProperties
  • Constructor Details

    • ExtensibleData

      protected ExtensibleData()
    • ExtensibleData

      protected ExtensibleData(ExtensibleData copy)
  • Method Details

    • getId

      public String getId()
      A local, context-specific id for the data.
      Returns:
      A local, context-specific id for the data.
    • setId

      public void setId(String id)
      A local, context-specific id for the data.
      Parameters:
      id - A local, context-specific id for the data.
    • id

      public ExtensibleData id(String id)
      Build up this object with an id.
      Parameters:
      id - The id.
      Returns:
      this.
    • getExtensionElements

      public List<Object> getExtensionElements()
      Custom extension elements for a conclusion.
      Specified by:
      getExtensionElements in interface SupportsExtensionElements
      Returns:
      Custom extension elements for a conclusion.
    • setExtensionElements

      public void setExtensionElements(List<Object> extensionElements)
      Custom extension elements for a conclusion.
      Parameters:
      extensionElements - Custom extension elements for a conclusion.
    • addExtensionElement

      public void addExtensionElement(Object element)
      Add an extension element.
      Specified by:
      addExtensionElement in interface SupportsExtensionElements
      Parameters:
      element - The extension element to add.
    • extensionElement

      public ExtensibleData extensionElement(Object element)
    • removeExtensionElements

      public <E> List<E> removeExtensionElements(Class<E> clazz)
      Remove extension elements of a given type.
      Type Parameters:
      E - The type of extension elements.
      Parameters:
      clazz - The type of extension element to remove.
      Returns:
      The removed extension elements.
    • setExtensionElement

      public void setExtensionElement(Object element)
      Sets an extension element by first removing all previous elements of the same type, then adding it to the list.
      Parameters:
      element - The element to set.
    • findExtensionOfType

      public <E> E findExtensionOfType(Class<E> clazz)
      Finds the first extension of a specified type.
      Specified by:
      findExtensionOfType in interface SupportsExtensionElements
      Type Parameters:
      E - The type of extension elements.
      Parameters:
      clazz - The type.
      Returns:
      The extension, or null if none found.
    • findExtensionsOfType

      public <E> List<E> findExtensionsOfType(Class<E> clazz)
      Find the extensions of a specified type.
      Specified by:
      findExtensionsOfType in interface SupportsExtensionElements
      Type Parameters:
      E - The type.
      Parameters:
      clazz - The type.
      Returns:
      The extensions, possibly empty but not null.
    • findExtensionOfType

      public <E> E findExtensionOfType(Class<E> clazz, String name, String namespace)
      Finds the first extension of a specified type in the given name and namespace.
      Type Parameters:
      E - The type of extension elements.
      Parameters:
      clazz - The type.
      name - The name of the extension element.
      namespace - The namespace of the extension element.
      Returns:
      The extension, or null if none found.
    • findExtensionsOfType

      public <E> List<E> findExtensionsOfType(Class<E> clazz, String name, String namespace)
      Find the extension elements of a specified type in the given name and namespace.
      Type Parameters:
      E - The type of extension elements.
      Parameters:
      clazz - The type of the extension element.
      name - The name of the extension element.
      namespace - The namespace of the extension element.
      Returns:
      The extensions, possibly empty but not null.
    • getTransientProperties

      public Map<String,Object> getTransientProperties()
      Get the transient properties.
      Specified by:
      getTransientProperties in interface HasTransientProperties
      Returns:
      the transient properties.
    • getTransientProperty

      public Object getTransientProperty(String name)
      Get a transient (non-serialized) property.
      Specified by:
      getTransientProperty in interface HasTransientProperties
      Parameters:
      name - The name of the property.
      Returns:
      The property.
    • setTransientProperty

      public void setTransientProperty(String name, Object value)
      Set a transient (non-serialized) property.
      Specified by:
      setTransientProperty in interface HasTransientProperties
      Parameters:
      name - the name of the property.
      value - the property value.
    • embed

      protected void embed(ExtensibleData data)
    • toString

      public String toString()
      Provide a simple toString() method.
      Overrides:
      toString in class Object