Package org.gedcomx.common
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 Summary
Fields Modifier and Type Field Description protected List<Object>extensionElementsprotected Map<String,Object>transientProperties
-
Constructor Summary
Constructors Constructor Description ExtensibleData()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddExtensionElement(Object element)Add an extension element.protected voidembed(ExtensibleData data)ExtensibleDataextensionElement(Object element)<E> EfindExtensionOfType(Class<E> clazz)Finds the first extension of a specified type.<E> EfindExtensionOfType(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.StringgetId()A local, context-specific id for the data.Map<String,Object>getTransientProperties()Get the transient properties.ObjectgetTransientProperty(String name)Get a transient (non-serialized) property.ExtensibleDataid(String id)Build up this object with an id.<E> List<E>removeExtensionElements(Class<E> clazz)Remove extension elements of a given type.voidsetExtensionElement(Object element)Sets an extension element by first removing all previous elements of the same type, then adding it to the list.voidsetExtensionElements(List<Object> extensionElements)Custom extension elements for a conclusion.voidsetId(String id)A local, context-specific id for the data.voidsetTransientProperty(String name, Object value)Set a transient (non-serialized) property.StringtoString()Provide a simple toString() method.
-
-
-
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.- Returns:
- this.
-
getExtensionElements
public List<Object> getExtensionElements()
Custom extension elements for a conclusion.- Specified by:
getExtensionElementsin interfaceSupportsExtensionElements- 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:
addExtensionElementin interfaceSupportsExtensionElements- 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:
findExtensionOfTypein interfaceSupportsExtensionElements- 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:
findExtensionsOfTypein interfaceSupportsExtensionElements- 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:
getTransientPropertiesin interfaceHasTransientProperties- Returns:
- the transient properties.
-
getTransientProperty
public Object getTransientProperty(String name)
Get a transient (non-serialized) property.- Specified by:
getTransientPropertyin interfaceHasTransientProperties- 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:
setTransientPropertyin interfaceHasTransientProperties- Parameters:
name- the name of the property.value- the property value.
-
embed
protected void embed(ExtensibleData data)
-
-