Created
November 9, 2014 05:48
-
-
Save sheimi/f712534c8d182984976a to your computer and use it in GitHub Desktop.
code in blog.sheimi.me: 2012-06-20-software-architecture-review-4 (2)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class Proxy { | |
public static void main(String[] args) { | |
} | |
} | |
class ThreeD<T, V, W> { | |
private T t; | |
private V v; | |
private W w; | |
public ThreeD(T t, V v, W w) { | |
this.t = t; | |
this.v = v; | |
this.w = w; | |
} | |
public T getA() { return t;} | |
public V getB() { return v;} | |
public W getC() { return w;} | |
} | |
interface IDataList<T, V, W> { | |
public T getA(int i) throws Exception; | |
public V getB(int i) throws Exception; | |
public W getC(int i) throws Exception; | |
public int size(); | |
} | |
abstract class DataListProxy<T, V, W> implements IDataList<T, V, W> { | |
protected IDataList<T, V, W> real; | |
public DataListProxy(IDataList<T, V, W> real) {this.real = real;} | |
public T getA(int i) throws Exception {throw new Exception(); } | |
public V getB(int i) throws Exception {throw new Exception(); } | |
public W getC(int i) throws Exception {throw new Exception(); } | |
public int size() { return real.size(); } | |
} | |
class DataListProxyA<T, V, W> extends DataListProxy<T, V, W> { | |
public DataListProxyA(IDataList<T, V, W> real) {super(real);} | |
public T getA(int i) throws Exception {return real.getA(i); } | |
} | |
class DataListProxyB<T, V, W> extends DataListProxy<T, V, W> { | |
public DataListProxyB(IDataList<T, V, W> real) {super(real);} | |
public V getB(int i) throws Exception {return real.getB(i); } | |
} | |
class DataListProxyC<T, V, W> extends DataListProxy<T, V, W> { | |
public DataListProxyC(IDataList<T, V, W> real) {super(real);} | |
public W getC(int i) throws Exception {return real.getC(i); } | |
} | |
class DataList<T, V, W> implements IDataList<T, V, W> { | |
private ArrayList<ThreeD<T, V, W>> list = new ArrayList<ThreeD<T, V, W>>(); | |
public void add(ThreeD<T, V, W> d) { list.add(d); } | |
public ThreeD<T, V, W> get(int index) { return list.get(index); } | |
public int size() {return list.size();} | |
public T getA(int i) { return list.get(i).getA(); } | |
public V getB(int i) { return list.get(i).getB(); } | |
public W getC(int i) { return list.get(i).getC(); } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment