1 8 14 package jfun.yan; 15 16 17 23 final class MappedComponent3<A,B,C,R> extends Component<R> { 24 private final Map3<A,B,C,R> m; 25 private final Creator<A> c1; 26 private final Creator<B> c2; 27 private final Creator<C> c3; 28 public boolean isConcrete(){ 29 return false; 30 } 31 34 public MappedComponent3(Creator<A> c1, Creator<B> c2, Creator<C> c3, Map3<A,B,C,R> m) { 35 this.c1 = c1; 36 this.c2 = c2; 37 this.c3 = c3; 38 this.m = m; 39 } 40 public Class <R> getType(){ 41 return null; 42 } 43 public R create(Dependency dep){ 44 return run_map(c1.create(dep), c2.create(dep), c3.create(dep)); 45 } 46 public Class verify(Dependency dep){ 47 c1.verify(dep); 48 c2.verify(dep); 49 c3.verify(dep); 50 return Object .class; 51 } 52 53 public boolean equals(Object obj) { 54 if(obj instanceof MappedComponent3){ 55 final MappedComponent3 mc2 = (MappedComponent3)obj; 56 return m.equals(mc2.m) && c1.equals(mc2.c1) && c2.equals(mc2.c2) 57 && c3.equals(mc2.c3); 58 } 59 else return false; 60 } 61 public int hashCode(){ 62 return 31*(c1.hashCode()*31 + c2.hashCode()) + c3.hashCode(); 63 } 64 public String toString(){ 65 return "map (" + c1.toString() + "," + c2.toString() + "," + c3 + ")"; 66 } 67 private R run_map(A o1, B o2, C o3){ 68 try{ 69 return m.map(o1, o2, o3); 70 } 71 catch(Error e){ 72 throw e; 73 } 74 catch(YanException e){ 75 throw e; 76 } 77 catch(Throwable e){ 78 throw new jfun.yan.ComponentInstantiationException(e); 79 } 80 } 81 public boolean isSingleton(){ 82 return false; 83 } 84 } 85 | Popular Tags |