protected <T extends BpmnModelElementInstance> T getCreateSingleChild(BpmnModelElementInstance parent, Class<T> typeClass) { Collection<T> childrenOfType = parent.getChildElementsByType(typeClass); if (childrenOfType.isEmpty()) { return createChild(parent, typeClass); } else { if (childrenOfType.size() > 1) { throw new BpmnModelException("Element " + parent + " of type " + parent.getElementType().getTypeName() + " has more than one child element of type " + typeClass.getName()); } else { return childrenOfType.iterator().next(); } } }
protected <T extends BpmnModelElementInstance> T getCreateSingleChild(BpmnModelElementInstance parent, Class<T> typeClass) { Collection<T> childrenOfType = parent.getChildElementsByType(typeClass); if (childrenOfType.isEmpty()) { return createChild(parent, typeClass); } else { if (childrenOfType.size() > 1) { throw new BpmnModelException("Element " + parent + " of type " + parent.getElementType().getTypeName() + " has more than one child element of type " + typeClass.getName()); } else { return childrenOfType.iterator().next(); } } }
protected <T extends BpmnModelElementInstance> T getCreateSingleChild(BpmnModelElementInstance parent, Class<T> typeClass) { Collection<T> childrenOfType = parent.getChildElementsByType(typeClass); if (childrenOfType.isEmpty()) { return createChild(parent, typeClass); } else { if (childrenOfType.size() > 1) { throw new BpmnModelException("Element " + parent + " of type " + parent.getElementType().getTypeName() + " has more than one child element of type " + typeClass.getName()); } else { return childrenOfType.iterator().next(); } } }