1 | package com.hammurapi.store; |
2 | |
3 | import java.util.Comparator; |
4 | import java.util.Iterator; |
5 | import java.util.concurrent.locks.Lock; |
6 | |
7 | import com.hammurapi.extract.Extractor; |
8 | import com.hammurapi.extract.Predicate; |
9 | import com.hammurapi.store.Index.Type; |
10 | |
11 | public class UnmodifiableStore<T,PK, S extends Store<T,PK,S>> implements Store<T,PK, S> { |
12 | |
13 | protected S master; |
14 | |
15 | public Iterator<T> iterator() { |
16 | return master.iterator(); |
17 | } |
18 | |
19 | public Handle<T, PK, S> put(T obj, Predicate<T, S>... validators) { |
20 | throw new UnsupportedOperationException(); |
21 | } |
22 | |
23 | public Iterable<T> getAll() { |
24 | return master.getAll(); |
25 | } |
26 | |
27 | public int queryAll(QueryTask<T, PK, S> processor) { |
28 | return master.queryAll(processor); |
29 | } |
30 | |
31 | public T getByPrimaryKey(PK primaryKey) { |
32 | return master.getByPrimaryKey(primaryKey); |
33 | } |
34 | |
35 | public Iterable<T> get(Predicate<T, S> selector) { |
36 | return master.get(selector); |
37 | } |
38 | |
39 | public int query(Predicate<T, S> selector, QueryTask<T, PK, S> processor) { |
40 | return master.query(selector, processor); |
41 | } |
42 | |
43 | public <V> int query(Predicate<T, S> selector, |
44 | Extractor<T, V, S> extractor, |
45 | QueryTask<V, PK, S> processor) { |
46 | return master.query(selector, extractor, processor); |
47 | } |
48 | |
49 | public Lock readLock() { |
50 | return master.readLock(); |
51 | } |
52 | |
53 | public Lock writeLock() { |
54 | return master.writeLock(); |
55 | } |
56 | |
57 | public <V> int queryMultiple(Predicate<T, S> selector, |
58 | Extractor<T, Iterable<V>, S> extractor, |
59 | Predicate<V, S> valueSelector, |
60 | QueryTask<V, PK, S> processor) { |
61 | return master.queryMultiple(selector, extractor, valueSelector, processor); |
62 | } |
63 | |
64 | public <V> Iterable<V> get(Predicate<T, S> selector, |
65 | Extractor<T, V, S> extractor, boolean ordered, |
66 | Comparator<V> comparator) { |
67 | return master.get(selector, extractor, ordered, comparator); |
68 | } |
69 | |
70 | public <V> Iterable<V> getMultiple(Predicate<T, S> selector, |
71 | Extractor<T, Iterable<V>, S> extractor, |
72 | Predicate<V, S> valueSelector, boolean ordered, |
73 | Comparator<V> comparator) { |
74 | return master.getMultiple(selector, extractor, valueSelector, ordered, comparator); |
75 | } |
76 | |
77 | public void clear() { |
78 | throw new UnsupportedOperationException(); |
79 | } |
80 | |
81 | public boolean remove(T obj) { |
82 | throw new UnsupportedOperationException(); |
83 | } |
84 | |
85 | public boolean removeByPrimaryKey(PK primaryKey) { |
86 | throw new UnsupportedOperationException(); |
87 | } |
88 | |
89 | public int remove(Predicate<T, S> selector) { |
90 | throw new UnsupportedOperationException(); |
91 | } |
92 | |
93 | public int update(Predicate<T, S> selector, UpdateTask<T, PK, S> updater) { |
94 | throw new UnsupportedOperationException(); |
95 | } |
96 | |
97 | public <V> Index<T, PK, V, S> addIndex(Predicate<T, S> predicate, |
98 | Extractor<T, V, S> extractor, Type type, |
99 | boolean ordered, Comparator<V> comparator) { |
100 | throw new UnsupportedOperationException(); |
101 | } |
102 | |
103 | public Extractor<T, PK, S> getPrimaryKeyExtractor() { |
104 | return master.getPrimaryKeyExtractor(); |
105 | } |
106 | |
107 | public S createView(Predicate<T, S> selector, ViewType viewType) { |
108 | return master.createView(selector, viewType); |
109 | } |
110 | |
111 | public UnmodifiableStore(S master) { |
112 | this.master = master; |
113 | } |
114 | |
115 | protected S getMaster() { |
116 | return master; |
117 | } |
118 | |
119 | @Override |
120 | public S createUnmodifiableFacade() { |
121 | return (S) this; |
122 | } |
123 | } |