1 16 17 package org.springframework.beans.factory.xml; 18 19 import java.util.Collections ; 20 import java.util.List ; 21 22 import org.springframework.beans.TestBean; 23 24 30 public class FactoryMethods { 31 32 public static FactoryMethods defaultInstance() { 33 TestBean tb = new TestBean(); 34 tb.setName("defaultInstance"); 35 return new FactoryMethods(tb, "default", 0); 36 } 37 38 41 public static FactoryMethods newInstance(TestBean tb) { 42 return new FactoryMethods(tb, "default", 0); 43 } 44 45 public static FactoryMethods newInstance(TestBean tb, int num, String name) { 46 if (name == null) { 47 throw new IllegalStateException ("Should never be called with null value"); 48 } 49 return new FactoryMethods(tb, name, num); 50 } 51 52 public static FactoryMethods newInstance(TestBean tb, int num, Integer something) { 53 if (something != null) { 54 throw new IllegalStateException ("Should never be called with non-null value"); 55 } 56 return new FactoryMethods(tb, null, num); 57 } 58 59 public static List listInstance() { 60 return Collections.EMPTY_LIST; 61 } 62 63 64 private int num = 0; 65 private String name = "default"; 66 private TestBean tb; 67 private String stringValue; 68 69 70 74 private FactoryMethods(TestBean tb, String name, int num) { 75 this.tb = tb; 76 this.name = name; 77 this.num = num; 78 } 79 80 public void setStringValue(String stringValue) { 81 this.stringValue = stringValue; 82 } 83 84 public String getStringValue() { 85 return this.stringValue; 86 } 87 88 public TestBean getTestBean() { 89 return this.tb; 90 } 91 92 public int getNum() { 93 return num; 94 } 95 96 public String getName() { 97 return name; 98 } 99 100 103 public void setName(String name) { 104 this.name = name; 105 } 106 107 } 108 | Popular Tags |