1 8 9 15 package jfun.yan; 16 17 import jfun.yan.factory.Factory; 18 19 29 final class TheFactoryComponent<T> extends Component<Factory<T>> { 30 private final Creator<T> cc; 31 private final String text; 32 private interface SerializableFactory<T> extends Factory<T>, java.io.Serializable {} 33 TheFactoryComponent(final Creator<T> cc, String text) { 34 this.cc = cc; 35 this.text = text; 36 } 37 38 public Class <Factory<T>> getType() { 39 return (Class )Factory.class; 40 } 41 public boolean isConcrete(){ 42 return true; 43 } 44 public Factory<T> create(final Dependency dep){ 45 return new SerializableFactory<T>(){ 46 public T create(){ 47 return cc.create(dep); 48 } 49 public String toString(){ 50 return text; 51 } 52 }; 53 } 54 public Class verify(final Dependency dep){ 55 cc.verify(dep); 56 return getType(); 57 } 58 public boolean equals(Object obj) { 59 if(obj instanceof TheFactoryComponent){ 60 final TheFactoryComponent other = (TheFactoryComponent)obj; 61 return cc.equals(other.cc); 62 } 63 else return false; 64 } 65 public int hashCode() { 66 return cc.hashCode(); 67 } 68 public String toString() { 69 return text; 71 } 72 public boolean isSingleton(){ 73 return false; 74 } 75 } 76 | Popular Tags |