public final class TLcdDataModel extends Object implements ILcdAnnotatedElement
A data model is a collection of types that forms a logical entity. Conceptually this is similar to a UML package or an XML schema. A data model is identified by a unique name. Some examples of instances supported by LuciadLightspeed are the AIXM5 and GML32 data models.
A data model has an explicit collection of dependent data models (see getDependencies()
).
Typically, these data models are needed when
creating data objects for the types declared in this data model. The dependencies
include, but are not limited to, the following data models:
Two data model instances are considered to be equal if they have the same name.
TLcdDataModel
provides direct access to its declared types (getDeclaredTypes()
).
It also provides access to all the types which are reachable from the data model. This is the union
of this data model's declared types with all the type declared by its dependencies.
Anonymous data models are data models that have no name and have no
declared types. They only have dependencies. An anonymous data model is never a dependency
for another data model. They are equal
to other anonymous data models that have the same set of dependencies. Anonymous
data models are typically used to represent a collection of data models as a single
data model. The data model offered by an ILcdDataModelDescriptor
is an example
where such an anonymous data model is often used.
Application-specific meta data can be represented using annotations. See ILcdAnnotatedElement
for
more details on this. A simple example for data models that are derived from an XML schema
could be the name space URI. This URI can't be set directly on a data model; however it
can be associated with the data model using an annotation. This allows other applications to
retrieve it easily.
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 implemented such that they are thread safe.
Data models are created using aTLcdDataModelBuilder
. Such a builder provides an
extensive API to define a new data model including all the types and properties it declares.
Consult the Introduction to the data modeling API for more information.ILcdDataModelDescriptor
Modifier and Type | Method and Description |
---|---|
<T extends ILcdAnnotation> |
addAnnotation(ILcdAnnotation aAnnotation)
Adds the given annotation to this element.
|
boolean |
equals(Object obj) |
<T extends ILcdAnnotation> |
getAnnotation(Class<T> aAnnotationType)
Returns the element's annotation for the specified class if such an annotation is present,
else null.
|
Collection<ILcdAnnotation> |
getAnnotations()
Returns all annotations present on this element as an unmodifiable collection.
|
Set<TLcdDataModel> |
getDeclaredDependencies()
Returns all the declared dependencies of this data model.
|
TLcdDataType |
getDeclaredType(String aName)
Returns the type defined by this data model with the given name.
|
Set<TLcdDataType> |
getDeclaredTypes()
Returns a (unmodifiable) set of all types defined in this data model.
|
Set<TLcdDataModel> |
getDependencies()
Returns all the dependencies (transitively) of this data model.
|
TLcdDataModel |
getDependency(String aName)
Returns a dependent data model with the given name.
|
String |
getDisplayName()
Returns a displayable name for this data model, suitable for usage in user interfaces.
|
String |
getName()
Returns the name of this model.
|
Set<TLcdDataType> |
getTypes()
Returns a (unmodifiable) set of all types declared in this data model or one
of its dependencies.
|
int |
hashCode() |
boolean |
isAnnotationPresent(Class<? extends ILcdAnnotation> aAnnotationType)
Returns true if an annotation for the specified class is present on this element,
else false.
|
boolean |
isAnonymous()
Returns if this instance is anonymous.
|
<T extends ILcdAnnotation> |
removeAnnotation(Class<T> aAnnotationClass)
Removes the annotation of the given class from this element.
|
String |
toString() |
public Set<TLcdDataModel> getDependencies()
public Set<TLcdDataModel> getDeclaredDependencies()
public TLcdDataModel getDependency(String aName)
null
is returned.aName
- the name of the data model that is to be returned. Data model names are case sensitivepublic String getName()
null
for anonymous data models.public boolean isAnonymous()
public Set<TLcdDataType> getDeclaredTypes()
public TLcdDataType getDeclaredType(String aName)
null
is returned.aName
- the name of the type that should be returned. Type names are case sensitivepublic Set<TLcdDataType> getTypes()
public <T extends ILcdAnnotation> T getAnnotation(Class<T> aAnnotationType)
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.
getAnnotation
in interface ILcdAnnotatedElement
aAnnotationType
- - the Class object corresponding to the annotation typepublic boolean isAnnotationPresent(Class<? extends ILcdAnnotation> aAnnotationType)
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.
isAnnotationPresent
in interface ILcdAnnotatedElement
aAnnotationType
- the Class object corresponding to the annotation classpublic Collection<ILcdAnnotation> getAnnotations()
ILcdAnnotatedElement
getAnnotations
in interface ILcdAnnotatedElement
public String getDisplayName()
ILcdDataModelDisplayNameProvider
public <T extends ILcdAnnotation> T addAnnotation(ILcdAnnotation aAnnotation)
ILcdAnnotatedElement
addAnnotation
in interface ILcdAnnotatedElement
aAnnotation
- the annotation to addpublic <T extends ILcdAnnotation> T removeAnnotation(Class<T> aAnnotationClass)
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.
removeAnnotation
in interface ILcdAnnotatedElement
aAnnotationClass
- the class of annotation to remove