Package org.camunda.bpm.model.xml.impl
Class ModelInstanceImpl
- java.lang.Object
-
- org.camunda.bpm.model.xml.impl.ModelInstanceImpl
-
- All Implemented Interfaces:
ModelInstance
- Direct Known Subclasses:
BpmnModelInstanceImpl
,CmmnModelInstanceImpl
,DmnModelInstanceImpl
public class ModelInstanceImpl extends java.lang.Object implements ModelInstance
An instance of a model- Author:
- Daniel Meyer, Sebastian Menski
-
-
Field Summary
Fields Modifier and Type Field Description protected DomDocument
document
protected ModelImpl
model
protected ModelBuilder
modelBuilder
-
Constructor Summary
Constructors Constructor Description ModelInstanceImpl(ModelImpl model, ModelBuilder modelBuilder, DomDocument document)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ModelInstance
clone()
Copies the model instance but not the model.DomDocument
getDocument()
Returns the wrappedDomDocument
.ModelElementInstance
getDocumentElement()
Returns theModelElement
corresponding to the document element of this model or null if no document element exists.Model
getModel()
Returns the underlying model.<T extends ModelElementInstance>
TgetModelElementById(java.lang.String id)
Find a unique element of the model by id.<T extends ModelElementInstance>
java.util.Collection<T>getModelElementsByType(java.lang.Class<T> referencingClass)
Find all elements of a type.java.util.Collection<ModelElementInstance>
getModelElementsByType(ModelElementType type)
Find all elements of a type.<T extends ModelElementInstance>
TnewInstance(java.lang.Class<T> type)
Creates a new instance of type class.<T extends ModelElementInstance>
TnewInstance(java.lang.Class<T> type, java.lang.String id)
Creates a new instance of type class with user-defined id.<T extends ModelElementInstance>
TnewInstance(ModelElementType type)
Creates a new instance of type.<T extends ModelElementInstance>
TnewInstance(ModelElementType type, java.lang.String id)
Creates a new instance of type with user-defined id.ModelElementType
registerGenericType(java.lang.String namespaceUri, java.lang.String localName)
void
setDocumentElement(ModelElementInstance modelElement)
Updates the document element.ValidationResults
validate(java.util.Collection<ModelElementValidator<?>> validators)
Validate semantic properties of this model instance using a collection of validators.
-
-
-
Field Detail
-
document
protected final DomDocument document
-
model
protected ModelImpl model
-
modelBuilder
protected final ModelBuilder modelBuilder
-
-
Constructor Detail
-
ModelInstanceImpl
public ModelInstanceImpl(ModelImpl model, ModelBuilder modelBuilder, DomDocument document)
-
-
Method Detail
-
getDocument
public DomDocument getDocument()
Description copied from interface:ModelInstance
Returns the wrappedDomDocument
.- Specified by:
getDocument
in interfaceModelInstance
- Returns:
- the DOM document
-
getDocumentElement
public ModelElementInstance getDocumentElement()
Description copied from interface:ModelInstance
Returns theModelElement
corresponding to the document element of this model or null if no document element exists.- Specified by:
getDocumentElement
in interfaceModelInstance
- Returns:
- the document element or null
-
setDocumentElement
public void setDocumentElement(ModelElementInstance modelElement)
Description copied from interface:ModelInstance
Updates the document element.- Specified by:
setDocumentElement
in interfaceModelInstance
- Parameters:
modelElement
- the new document element to set
-
newInstance
public <T extends ModelElementInstance> T newInstance(java.lang.Class<T> type)
Description copied from interface:ModelInstance
Creates a new instance of type class.- Specified by:
newInstance
in interfaceModelInstance
- Type Parameters:
T
- instance type- Parameters:
type
- the class of the type to create- Returns:
- the new created instance
-
newInstance
public <T extends ModelElementInstance> T newInstance(java.lang.Class<T> type, java.lang.String id)
Description copied from interface:ModelInstance
Creates a new instance of type class with user-defined id.- Specified by:
newInstance
in interfaceModelInstance
- Type Parameters:
T
- instance type- Parameters:
type
- the class of the type to createid
- identifier of new element instance- Returns:
- the new created instance
-
newInstance
public <T extends ModelElementInstance> T newInstance(ModelElementType type)
Description copied from interface:ModelInstance
Creates a new instance of type.- Specified by:
newInstance
in interfaceModelInstance
- Type Parameters:
T
- instance type- Parameters:
type
- the type to create- Returns:
- the new created instance
-
newInstance
public <T extends ModelElementInstance> T newInstance(ModelElementType type, java.lang.String id)
Description copied from interface:ModelInstance
Creates a new instance of type with user-defined id.- Specified by:
newInstance
in interfaceModelInstance
- Type Parameters:
T
- instance type- Parameters:
type
- the type to createid
- identifier of new element instance- Returns:
- the new created instance
-
getModel
public Model getModel()
Description copied from interface:ModelInstance
Returns the underlying model.- Specified by:
getModel
in interfaceModelInstance
- Returns:
- the model
-
registerGenericType
public ModelElementType registerGenericType(java.lang.String namespaceUri, java.lang.String localName)
-
getModelElementById
public <T extends ModelElementInstance> T getModelElementById(java.lang.String id)
Description copied from interface:ModelInstance
Find a unique element of the model by id.- Specified by:
getModelElementById
in interfaceModelInstance
- Parameters:
id
- the id of the element- Returns:
- the element with the id or null
-
getModelElementsByType
public java.util.Collection<ModelElementInstance> getModelElementsByType(ModelElementType type)
Description copied from interface:ModelInstance
Find all elements of a type.- Specified by:
getModelElementsByType
in interfaceModelInstance
- Parameters:
type
- the type of the elements- Returns:
- the collection of elements of the type
-
getModelElementsByType
public <T extends ModelElementInstance> java.util.Collection<T> getModelElementsByType(java.lang.Class<T> referencingClass)
Description copied from interface:ModelInstance
Find all elements of a type.- Specified by:
getModelElementsByType
in interfaceModelInstance
- Parameters:
referencingClass
- the type class of the elements- Returns:
- the collection of elements of the type
-
clone
public ModelInstance clone()
Description copied from interface:ModelInstance
Copies the model instance but not the model. So only the wrapped DOM document is cloned. Changes of the model are persistent between multiple model instances.- Specified by:
clone
in interfaceModelInstance
- Overrides:
clone
in classjava.lang.Object
- Returns:
- the new model instance
-
validate
public ValidationResults validate(java.util.Collection<ModelElementValidator<?>> validators)
Description copied from interface:ModelInstance
Validate semantic properties of this model instance using a collection of validators. ModelElementValidator is an SPI that can be implemented by the user to execute custom validation logic on the model. The validation results are collected into aValidationResults
object which is returned by this method.- Specified by:
validate
in interfaceModelInstance
- Parameters:
validators
- the validators to execute- Returns:
- the results of the validation.
-
-