org.gedcomx.common
Class ExtensibleData

java.lang.Object
  extended by 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 Summary
protected  List<Object> extensionElements
           
protected  Map<String,Object> transientProperties
           
 
Constructor Summary
ExtensibleData()
           
 
Method Summary
 void addExtensionElement(Object element)
          Add an extension element.
protected  void embed(ExtensibleData data)
           
<E> E
findExtensionOfType(Class<E> clazz)
          Finds the first extension of a specified type.
<E> E
findExtensionOfType(Class<E> clazz, String name, String namespace)
          Finds the first extension of a specified type in the given name and namespace.
<E> List<E>
findExtensionsOfType(Class<E> clazz)
          Find the extensions of a specified type.
<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.
 List<Object> getExtensionElements()
          Custom extension elements for a conclusion.
 String getId()
          A local, context-specific id for the data.
 Map<String,Object> getTransientProperties()
          Get the transient properties.
 Object getTransientProperty(String name)
          Get a transient (non-serialized) property.
 ExtensibleData id(String id)
          Build up this object with an id.
<E> List<E>
removeExtensionElements(Class<E> clazz)
          Remove extension elements of a given type.
 void setExtensionElement(Object element)
          Sets an extension element by first removing all previous elements of the same type, then adding it to the list.
 void setExtensionElements(List<Object> extensionElements)
          Custom extension elements for a conclusion.
 void setId(String id)
          A local, context-specific id for the data.
 void setTransientProperty(String name, Object value)
          Set a transient (non-serialized) property.
 String toString()
          Provide a simple toString() method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

extensionElements

protected List<Object> extensionElements

transientProperties

protected final Map<String,Object> transientProperties
Constructor Detail

ExtensibleData

public ExtensibleData()
Method Detail

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.

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.

removeExtensionElements

public <E> List<E> removeExtensionElements(Class<E> clazz)
Remove extension elements of a given type.

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
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
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.

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.

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


Copyright © 2015. All rights reserved.