MicroSpaceDelegator.java

package org.microspace.space;

import java.util.List;

import org.microspace.event.SpaceRecordListener;
import org.microspace.specific.CurrentTimeProvider;
import org.microspace.table.query.TableQuery;
import org.microspace.util.UniqueId;

/**
 * A delegator that delegates all methods to MicroSpace.
 * 
 * @author Gaspar Sinai {@literal gaspar.sinai@microspace.org}
 * @version 2018-11-27
 */
public class MicroSpaceDelegator implements MicroSpace {
	
	private final MicroSpace delegate;
	private final UniqueId spaceId;
	
	public MicroSpaceDelegator (MicroSpace space) {
		this.delegate = space;
		this.spaceId = null;
	}
	public MicroSpaceDelegator (MicroSpace space, UniqueId spaceId) {
		this.delegate = space;
		this.spaceId = spaceId;
	}
	@Override
	public void commit() {
		delegate.commit();
	}

	@Override
	public void rollback() {
		delegate.rollback();
	}

	@Override
	public <T> void write(T object) {
		delegate.write(object);
	}

	@Override
	public <T> T take(TableQuery<T> query) {
		return delegate.take(query);
	}

	@Override
	public <T> T take(TableQuery<T> query, long timeout) {
		return delegate.take(query, timeout);
	}

	@Override
	public <T> List<T> takeMultiple(TableQuery<T> query) {
		return delegate.takeMultiple(query);
	}

	@Override
	public <T> T read(TableQuery<T> query) {
		return delegate.read(query);
	}

	@Override
	public <T> T getNextMessage(TableQuery<T> query) {
		return delegate.getNextMessage(query);
	}

	@Override
	public <T> T getNextMessage(TableQuery<T> query, long timeout) {
		return delegate.getNextMessage(query, timeout);
	}

	@Override
	public <T> List<T> readMultiple(TableQuery<T> query) {
		return delegate.readMultiple(query);
	}

	@Override
	public <T> T take(T templateObject) {
		return delegate.take(templateObject);
	}

	@Override
	public <T> T take(T templateObject, long timeout) {
		return delegate.take(templateObject, timeout);
	}

	@Override
	public <T> List<T> takeMultiple(T templateObject) {
		return delegate.takeMultiple(templateObject);
	}

	@Override
	public <T> T read(T templateObject) {
		return delegate.read(templateObject);
	}

	@Override
	public <T> T getNextMessage(T templateObject) {
		return delegate.getNextMessage(templateObject);
	}

	@Override
	public <T> T getNextMessage(T templateObject, long timeout) {
		return delegate.getNextMessage(templateObject, timeout);
	}

	@Override
	public <T> List<T> readMultiple(T templateObject) {
		return delegate.readMultiple(templateObject);
	}

	@Override
	public <T> List<T> readMultiple(T templateObject, int maxEntries) {
		return delegate.readMultiple(templateObject, maxEntries);
	}

	@Override
	public <T> T readById(Class<T> tableClass, Object primaryKey) {
		return delegate.readById(tableClass, primaryKey);
	}

	@Override
	public <T> T takeById(Class<T> tableClass, Object primaryKey) {
		return delegate.takeById(tableClass, primaryKey);
	}

	@Override
	public <T> T readByIdOf(T initializedObject) {
		return delegate.readByIdOf(initializedObject);
	}

	@Override
	public <T> T takeByIdOf(T initializedObject) {
		return delegate.takeByIdOf(initializedObject);
	}

	@Override
	public List<Class<?>> getTableClasses() {
		return delegate.getTableClasses();
	}

	@Override
	public <T> void registerMessageQueue(TableQuery<T> query) {
		delegate.registerMessageQueue(query);
	}

	@Override
	public <T> void registerMessageQueue(T templateObject) {
		delegate.registerMessageQueue(templateObject);
		
	}

	@Override
	public <T> void unregisterMessageQueue(TableQuery<T> query) {
		delegate.unregisterMessageQueue(query);
	}

	@Override
	public <T> void unregisterMessageQueue(T templateObject) {
		delegate.unregisterMessageQueue(templateObject);
	}

	@Override
	public <T> List<TableQuery<T>> getRegisteredMessageQueueQueries(Class<T> clazz) {
		return delegate.getRegisteredMessageQueueQueries(clazz);
	}

	@Override
	public <T> int getMessageQueueSize(TableQuery<T> query) {
		return delegate.getMessageQueueSize(query);
	}

	@Override
	public <T> void clear(Class<T> clazz) {
		delegate.clear(clazz);
		
	}

	@Override
	public void clear() {
		delegate.clear();
	}

	@Override
	public <T> int size(Class<T> clazz) {
		return delegate.size(clazz);
	}

	@Override
	public int size() {
		return delegate.size();
	}

	@Override
	public AccessorGenerator getAccessorGenerator() {
		return delegate.getAccessorGenerator();
	}

	@Override
	public boolean isRemoteSpace() {
		return delegate.isRemoteSpace();
	}

	@Override
	public boolean isInterrupted() {
		return delegate.isInterrupted();
	}

	@Override
	public Integer getPartitionId() {
		return delegate.getPartitionId();
	}

	@Override
	public UniqueId getSpaceInstanceId() {
		if (spaceId == null) {
			return delegate.getSpaceInstanceId();
		}
		return spaceId;
	}

	@Override
	public void setSpaceRecordListener(SpaceRecordListener listener) {
		delegate.setSpaceRecordListener(listener);
	}
	/**
	 * Get the current Time provider.
	 * @return The current time provider for timestamps.
	 */
	public CurrentTimeProvider getCurrentTimeProvider() {
		return delegate.getCurrentTimeProvider();
	}

}