    001package com.hammurapi.store;
    002
    003import java.util.Comparator;
    004import java.util.Iterator;
    005import java.util.concurrent.locks.Lock;
    006
    007import com.hammurapi.extract.Extractor;
    008import com.hammurapi.extract.Predicate;
    009import com.hammurapi.store.Index.Type;
    010
    011public class UnmodifiableStore<T,PK, S extends Store<T,PK,S>> implements Store<T,PK, S> {
    012
    013        protected S master;
    014
    015        public Iterator<T> iterator() {
    016                return master.iterator();
    017        }
    018
    019        public Handle<T, PK, S> put(T obj, Predicate<T, S>... validators) {
    020                throw new UnsupportedOperationException();
    021        }
    022
    023        public Iterable<T> getAll() {
    024                return master.getAll();
    025        }
    026
    027        public int queryAll(QueryTask<T, PK, S> processor) {
    028                return master.queryAll(processor);
    029        }
    030
    031        public T getByPrimaryKey(PK primaryKey) {
    032                return master.getByPrimaryKey(primaryKey);
    033        }
    034
    035        public Iterable<T> get(Predicate<T, S> selector) {
    036                return master.get(selector);
    037        }
    038
    039        public int query(Predicate<T, S> selector, QueryTask<T, PK, S> processor) {
    040                return master.query(selector, processor);
    041        }
    042
    043        public <V> int query(Predicate<T, S> selector,
    044                        Extractor<T, V, S> extractor,
    045                        QueryTask<V, PK, S> processor) {
    046                return master.query(selector, extractor, processor);
    047        }
    048
    049        public Lock readLock() {
    050                return master.readLock();
    051        }
    052
    053        public Lock writeLock() {
    054                return master.writeLock();
    055        }
    056
    057        public <V> int queryMultiple(Predicate<T, S> selector,
    058                        Extractor<T, Iterable<V>, S> extractor,
    059                        Predicate<V, S> valueSelector,
    060                        QueryTask<V, PK, S> processor) {
    061                return master.queryMultiple(selector, extractor, valueSelector, processor);
    062        }
    063
    064        public <V> Iterable<V> get(Predicate<T, S> selector,
    065                        Extractor<T, V, S> extractor, boolean ordered,
    066                        Comparator<V> comparator) {
    067                return master.get(selector, extractor, ordered, comparator);
    068        }
    069
    070        public <V> Iterable<V> getMultiple(Predicate<T, S> selector,
    071                        Extractor<T, Iterable<V>, S> extractor,
    072                        Predicate<V, S> valueSelector, boolean ordered,
    073                        Comparator<V> comparator) {
    074                return master.getMultiple(selector, extractor, valueSelector, ordered, comparator);
    075        }
    076
    077        public void clear() {
    078                throw new UnsupportedOperationException();
    079        }
    080
    081        public boolean remove(T obj) {
    082                throw new UnsupportedOperationException();
    083        }
    084
    085        public boolean removeByPrimaryKey(PK primaryKey) {
    086                throw new UnsupportedOperationException();
    087        }
    088
    089        public int remove(Predicate<T, S> selector) {
    090                throw new UnsupportedOperationException();
    091        }
    092
    093        public int update(Predicate<T, S> selector, UpdateTask<T, PK, S> updater) {
    094                throw new UnsupportedOperationException();
    095        }
    096
    097        public <V, ST extends T> Index<T, ST, PK, V, S> addIndex(
    098                        Predicate<T, S> predicate,
    099                        Extractor<ST, V, S> extractor, Type type,
    100                        boolean ordered,
    101                        Comparator<V> comparator) {
    102                throw new UnsupportedOperationException();
    103        }
    104
    105        public Extractor<T, PK, S> getPrimaryKeyExtractor() {
    106                return master.getPrimaryKeyExtractor();
    107        }
    108
    109        public S createView(Predicate<T, S> selector,     ViewType viewType) {
    110                return master.createView(selector, viewType);
    111        }
    112
    113        public UnmodifiableStore(S master) {
    114                this.master = master;
    115        }
    116
    117        protected S getMaster() {
    118                return master;
    119        }
    120
    121        @Override
    122        public S createUnmodifiableFacade() {
    123                return (S) this;
    124        }
    125}