Search in sources :

Example 1 with ModelElementInstanceImpl

use of org.camunda.bpm.model.xml.impl.instance.ModelElementInstanceImpl in project camunda-xml-model by camunda.

the class ChildElementImpl method removeChild.

public boolean removeChild(ModelElementInstance element) {
    ModelElementInstanceImpl childElement = (ModelElementInstanceImpl) getChild(element);
    ModelElementInstanceImpl elementInstanceImpl = (ModelElementInstanceImpl) element;
    return elementInstanceImpl.removeChildElement(childElement);
}
Also used : ModelElementInstanceImpl(org.camunda.bpm.model.xml.impl.instance.ModelElementInstanceImpl)

Example 2 with ModelElementInstanceImpl

use of org.camunda.bpm.model.xml.impl.instance.ModelElementInstanceImpl in project camunda-xml-model by camunda.

the class ChildElementCollectionImpl method get.

public Collection<T> get(ModelElementInstance element) {
    final ModelElementInstanceImpl modelElement = (ModelElementInstanceImpl) element;
    return new Collection<T>() {

        public boolean contains(Object o) {
            if (o == null) {
                return false;
            } else if (!(o instanceof ModelElementInstanceImpl)) {
                return false;
            } else {
                return getView(modelElement).contains(((ModelElementInstanceImpl) o).getDomElement());
            }
        }

        public boolean containsAll(Collection<?> c) {
            for (Object elementToCheck : c) {
                if (!contains(elementToCheck)) {
                    return false;
                }
            }
            return true;
        }

        public boolean isEmpty() {
            return getView(modelElement).isEmpty();
        }

        public Iterator<T> iterator() {
            Collection<T> modelElementCollection = ModelUtil.getModelElementCollection(getView(modelElement), modelElement.getModelInstance());
            return modelElementCollection.iterator();
        }

        public Object[] toArray() {
            Collection<T> modelElementCollection = ModelUtil.getModelElementCollection(getView(modelElement), modelElement.getModelInstance());
            return modelElementCollection.toArray();
        }

        public <U> U[] toArray(U[] a) {
            Collection<T> modelElementCollection = ModelUtil.getModelElementCollection(getView(modelElement), modelElement.getModelInstance());
            return modelElementCollection.toArray(a);
        }

        public int size() {
            return getView(modelElement).size();
        }

        public boolean add(T e) {
            if (!isMutable) {
                throw new UnsupportedModelOperationException("add()", "collection is immutable");
            }
            performAddOperation(modelElement, e);
            return true;
        }

        public boolean addAll(Collection<? extends T> c) {
            if (!isMutable) {
                throw new UnsupportedModelOperationException("addAll()", "collection is immutable");
            }
            boolean result = false;
            for (T t : c) {
                result |= add(t);
            }
            return result;
        }

        public void clear() {
            if (!isMutable) {
                throw new UnsupportedModelOperationException("clear()", "collection is immutable");
            }
            Collection<DomElement> view = getView(modelElement);
            performClearOperation(modelElement, view);
        }

        public boolean remove(Object e) {
            if (!isMutable) {
                throw new UnsupportedModelOperationException("remove()", "collection is immutable");
            }
            ModelUtil.ensureInstanceOf(e, ModelElementInstanceImpl.class);
            return performRemoveOperation(modelElement, e);
        }

        public boolean removeAll(Collection<?> c) {
            if (!isMutable) {
                throw new UnsupportedModelOperationException("removeAll()", "collection is immutable");
            }
            boolean result = false;
            for (Object t : c) {
                result |= remove(t);
            }
            return result;
        }

        public boolean retainAll(Collection<?> c) {
            throw new UnsupportedModelOperationException("retainAll()", "not implemented");
        }
    };
}
Also used : ModelElementInstanceImpl(org.camunda.bpm.model.xml.impl.instance.ModelElementInstanceImpl) DomElement(org.camunda.bpm.model.xml.instance.DomElement) ChildElementCollection(org.camunda.bpm.model.xml.type.child.ChildElementCollection) Collection(java.util.Collection) UnsupportedModelOperationException(org.camunda.bpm.model.xml.UnsupportedModelOperationException)

Example 3 with ModelElementInstanceImpl

use of org.camunda.bpm.model.xml.impl.instance.ModelElementInstanceImpl in project camunda-xml-model by camunda.

the class ChildElementImpl method getChild.

@SuppressWarnings("unchecked")
public T getChild(ModelElementInstance element) {
    ModelElementInstanceImpl elementInstanceImpl = (ModelElementInstanceImpl) element;
    ModelElementInstance childElement = elementInstanceImpl.getUniqueChildElementByType(childElementTypeClass);
    if (childElement != null) {
        ModelUtil.ensureInstanceOf(childElement, childElementTypeClass);
        return (T) childElement;
    } else {
        return null;
    }
}
Also used : ModelElementInstanceImpl(org.camunda.bpm.model.xml.impl.instance.ModelElementInstanceImpl) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance)

Aggregations

ModelElementInstanceImpl (org.camunda.bpm.model.xml.impl.instance.ModelElementInstanceImpl)3 Collection (java.util.Collection)1 UnsupportedModelOperationException (org.camunda.bpm.model.xml.UnsupportedModelOperationException)1 DomElement (org.camunda.bpm.model.xml.instance.DomElement)1 ModelElementInstance (org.camunda.bpm.model.xml.instance.ModelElementInstance)1 ChildElementCollection (org.camunda.bpm.model.xml.type.child.ChildElementCollection)1