All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.umlg.runtime.collection.persistent.UmlgQualifiedOrderedSetImpl Maven / Gradle / Ivy

There is a newer version: 2.0.15
Show newest version
package org.umlg.runtime.collection.persistent;

import org.apache.tinkerpop.gremlin.structure.Edge;
import org.umlg.runtime.collection.UmlgQualifiedOrderedSet;
import org.umlg.runtime.collection.UmlgRuntimeProperty;
import org.umlg.runtime.domain.UmlgNode;

import java.util.Collection;
import java.util.Spliterator;
import java.util.Spliterators;

public class UmlgQualifiedOrderedSetImpl extends UmlgBaseOrderedSet implements UmlgQualifiedOrderedSet {

    @SuppressWarnings("unchecked")
    public UmlgQualifiedOrderedSetImpl(UmlgNode owner, UmlgRuntimeProperty runtimeProperty) {
        super(owner, runtimeProperty);
    }

    @Override
    public void add(int indexOf, E e) {
        maybeLoad();
        if (!this.getInternalListOrderedSet().contains(e)) {
            Edge edge = addToListAtIndex(indexOf, e);
            // Can only qualify TinkerNode's
            if (!(e instanceof UmlgNode)) {
                throw new IllegalStateException("Primitive properties can not be qualified!");
            }
        }
    }

    @Override
    public boolean addAll(Collection c) {
        throw new IllegalStateException("This method can not be called on a qualified association. Call add(E, List) instead");
    }

    @Override
    public boolean addAll(int index, Collection c) {
        throw new IllegalStateException("This method can not be called on a qualified association. Call add(E, List) instead");
    }

    @Override
    public E set(int index, E element) {
        throw new IllegalStateException("This method can not be called on a qualified association. Call add(E, List) instead");
    }

    @Override
    public Spliterator spliterator() {
        return Spliterators.spliterator(this, Spliterator.DISTINCT);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy