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