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);
}
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");
}
};
}
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;
}
}
Aggregations