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

com.buschmais.xo.impl.proxy.collection.RelationCollectionProxy Maven / Gradle / Ivy

The newest version!
package com.buschmais.xo.impl.proxy.collection;

import java.util.Collection;
import java.util.Iterator;

import com.buschmais.xo.api.metadata.method.RelationCollectionPropertyMethodMetadata;
import com.buschmais.xo.impl.SessionContext;

public class RelationCollectionProxy
    extends AbstractCollectionProxy> implements Collection {

    public RelationCollectionProxy(SessionContext sessionContext, Entity entity,
        RelationCollectionPropertyMethodMetadata metadata) {
        super(sessionContext, entity, metadata);
    }

    @Override
    public Iterator iterator() {
        final SessionContext sessionContext = getSessionContext();
        final Iterator iterator = sessionContext.getEntityPropertyManager()
            .getRelationCollection(getEntity(), getMetadata());
        return sessionContext.getInterceptorFactory()
            .addInterceptor(new Iterator() {

                @Override
                public boolean hasNext() {
                    return iterator.hasNext();
                }

                @Override
                public Instance next() {
                    return sessionContext.getRelationInstanceManager()
                        .readInstance(iterator.next());
                }

                @Override
                public void remove() {
                    throw new UnsupportedOperationException("Remove not supported");
                }
            }, Iterator.class);
    }

    @Override
    public boolean add(Instance instance) {
        throw new UnsupportedOperationException("Add not supported");
    }

    @Override
    public boolean remove(Object o) {
        throw new UnsupportedOperationException("Remove not supported");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy