org.umlg.runtime.collection.persistent.BaseSet Maven / Gradle / Ivy
package org.umlg.runtime.collection.persistent;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.umlg.runtime.collection.UmlgBag;
import org.umlg.runtime.collection.UmlgOrderedSet;
import org.umlg.runtime.collection.UmlgRuntimeProperty;
import org.umlg.runtime.collection.UmlgSet;
import org.umlg.runtime.collection.ocl.BodyExpressionEvaluator;
import org.umlg.runtime.collection.ocl.BooleanExpressionEvaluator;
import org.umlg.runtime.collection.ocl.OclStdLibSet;
import org.umlg.runtime.collection.ocl.OclStdLibSetImpl;
import org.umlg.runtime.domain.UmlgEnum;
import org.umlg.runtime.domain.UmlgNode;
import java.util.*;
public abstract class BaseSet extends BaseCollection implements UmlgSet, OclStdLibSet {
protected OclStdLibSet oclStdLibSet;
public BaseSet(UmlgRuntimeProperty runtimeProperty) {
super(runtimeProperty);
this.internalCollection = new HashSet<>();
this.oclStdLibSet = new OclStdLibSetImpl<>((Set)this.internalCollection);
this.oclStdLibCollection = this.oclStdLibSet;
}
public BaseSet(UmlgNode owner, PropertyTree propertyTree) {
super(owner, propertyTree);
this.internalCollection = new HashSet<>();
this.oclStdLibSet = new OclStdLibSetImpl<>((Set)this.internalCollection);
this.oclStdLibCollection = this.oclStdLibSet;
}
public BaseSet(UmlgNode owner, PropertyTree propertyTree, boolean loaded) {
super(owner, propertyTree, loaded);
this.internalCollection = new HashSet<>();
this.oclStdLibSet = new OclStdLibSetImpl<>((Set)this.internalCollection);
this.oclStdLibCollection = this.oclStdLibSet;
}
public BaseSet(UmlgNode owner, UmlgRuntimeProperty runtimeProperty) {
super(owner, runtimeProperty);
this.internalCollection = new HashSet<>();
this.oclStdLibSet = new OclStdLibSetImpl<>((Set)this.internalCollection);
this.oclStdLibCollection = this.oclStdLibSet;
}
public BaseSet(UmlgEnum owner, UmlgRuntimeProperty runtimeProperty) {
super(owner, runtimeProperty);
this.internalCollection = new HashSet();
this.oclStdLibSet = new OclStdLibSetImpl((Set)this.internalCollection);
this.oclStdLibCollection = this.oclStdLibSet;
}
@Override
protected void addToInverseLinkedList(Edge edge) {
if (!this.isControllingSide()) {
edge.property(BaseCollection.IN_EDGE_SEQUENCE_ID, (double)this.inverseCollectionSize);
} else {
edge.property(BaseCollection.OUT_EDGE_SEQUENCE_ID, (double)this.inverseCollectionSize);
}
}
@Override
protected Collection convertToArrayCollection() {
return new HashSet<>(this.internalCollection.size() + 1);
}
@Override
protected void addToLinkedList(Edge edge) {
throw new RuntimeException("addToLinkedList and manageLinkedListInverse should never be called for a BaseSet!");
}
protected Set getInternalSet() {
return (Set) this.internalCollection;
}
@Override
public void clear() {
maybeLoad();
//Use an ArrayList to avoid set logic calling getUid in hashCode
for (E e : new ArrayList<>(this.getInternalSet())) {
this.remove(e);
}
}
@Override
public UmlgBag collectNested(BodyExpressionEvaluator v) {
maybeLoad();
return this.oclStdLibSet.collectNested(v);
}
@Override
public UmlgBag collect(BodyExpressionEvaluator v) {
maybeLoad();
return this.oclStdLibSet.collect(v);
}
@Override
public UmlgSet flatten() {
maybeLoad();
return this.oclStdLibSet.flatten();
}
@Override
public UmlgSet select(BooleanExpressionEvaluator v) {
maybeLoad();
return this.oclStdLibSet.select(v);
}
@Override
public UmlgSet union(UmlgSet extends E> s) {
maybeLoad();
return this.oclStdLibSet.union(s);
}
@Override
public UmlgBag union(UmlgBag extends E> bag) {
maybeLoad();
return this.oclStdLibSet.union(bag);
}
@Override
public Boolean equals(UmlgSet s) {
maybeLoad();
return this.oclStdLibSet.equals(s);
}
@Override
public UmlgSet intersection(UmlgSet s) {
maybeLoad();
return this.oclStdLibSet.intersection(s);
}
@Override
public UmlgSet intersection(UmlgBag bag) {
maybeLoad();
return this.oclStdLibSet.intersection(bag);
}
@Override
public UmlgSet subtract(UmlgSet s) {
maybeLoad();
return this.oclStdLibSet.subtract(s);
}
@Override
public UmlgSet including(E e) {
maybeLoad();
return this.oclStdLibSet.including(e);
}
@Override
public UmlgSet excluding(E e) {
maybeLoad();
return this.oclStdLibSet.excluding(e);
}
@Override
public UmlgSet symmetricDifference(UmlgSet s) {
maybeLoad();
return this.oclStdLibSet.symmetricDifference(s);
}
@Override
public UmlgOrderedSet sortedBy(Comparator comparator) {
maybeLoad();
return this.oclStdLibSet.sortedBy(comparator);
}
}