* @throws ModelReferenceException if element is not already added to the model
*/
public void setReferenceTargetElement(ModelElementInstance referenceSourceElement, T referenceTargetElement) {
ModelInstance modelInstance = referenceSourceElement.getModelInstance();
String referenceTargetIdentifier = referenceTargetAttribute.getValue(referenceTargetElement);
ModelElementInstance existingElement = modelInstance.getModelElementById(referenceTargetIdentifier);
if(existingElement == null || !existingElement.equals(referenceTargetElement)) {
throw new ModelReferenceException("Cannot create reference to model element " + referenceTargetElement
+": element is not part of model. Please connect element to the model first.");
} else {
setReferenceIdentifier(referenceSourceElement, referenceTargetIdentifier);
}