1 package spoon.reflect; 2 3 import java.io.Serializable ; 4 5 import spoon.processing.Builder; 6 import spoon.processing.Environment; 7 import spoon.reflect.declaration.CtAnnotationType; 8 import spoon.reflect.declaration.CtClass; 9 import spoon.reflect.declaration.CtConstructor; 10 import spoon.reflect.declaration.CtEnum; 11 import spoon.reflect.declaration.CtExecutable; 12 import spoon.reflect.declaration.CtField; 13 import spoon.reflect.declaration.CtInterface; 14 import spoon.reflect.declaration.CtMethod; 15 import spoon.reflect.declaration.CtPackage; 16 import spoon.reflect.declaration.CtType; 17 import spoon.reflect.factory.AnnotationFactory; 18 import spoon.reflect.factory.ClassFactory; 19 import spoon.reflect.factory.CodeFactory; 20 import spoon.reflect.factory.ConstructorFactory; 21 import spoon.reflect.factory.EnumFactory; 22 import spoon.reflect.factory.EvalFactory; 23 import spoon.reflect.factory.ExecutableFactory; 24 import spoon.reflect.factory.FieldFactory; 25 import spoon.reflect.factory.InterfaceFactory; 26 import spoon.reflect.factory.MethodFactory; 27 import spoon.reflect.factory.PackageFactory; 28 import spoon.reflect.factory.TemplateFactory; 29 import spoon.reflect.factory.TypeFactory; 30 import spoon.support.DefaultCoreFactory; 31 import spoon.support.StandardEnvironment; 32 33 48 public class Factory implements Serializable { 49 50 private static final long serialVersionUID = 1L; 51 52 private transient AnnotationFactory Annotation; 53 54 57 public AnnotationFactory Annotation() { 58 if (Annotation == null) { 59 Annotation = new AnnotationFactory(this); 60 } 61 return Annotation; 62 } 63 64 private transient ClassFactory Class; 65 66 69 public ClassFactory Class() { 70 if (Class == null) { 71 Class = new ClassFactory(this); 72 } 73 return Class; 74 } 75 76 private transient CodeFactory Code; 77 78 81 public CodeFactory Code() { 82 if (Code == null) { 83 Code = new CodeFactory(this); 84 } 85 return Code; 86 } 87 88 private transient ConstructorFactory Constructor; 89 90 93 public ConstructorFactory Constructor() { 94 if (Constructor == null) { 95 Constructor = new ConstructorFactory(this); 96 } 97 return Constructor; 98 } 99 100 private CoreFactory Core; 101 102 105 public CoreFactory Core() { 106 if (Core == null) { 107 Core = new DefaultCoreFactory(); 108 } 109 return Core; 110 } 111 112 private transient EnumFactory Enum; 113 114 117 public EnumFactory Enum() { 118 if (Enum == null) { 119 Enum = new EnumFactory(this); 120 } 121 return Enum; 122 } 123 124 private Environment Environment; 125 126 129 public Environment getEnvironment() { 130 if (Environment == null) { 131 Environment = new StandardEnvironment(); 132 } 133 return Environment; 134 } 135 136 private transient ExecutableFactory Executable; 137 138 141 public ExecutableFactory Executable() { 142 if (Executable == null) { 143 Executable = new ExecutableFactory(this); 144 } 145 return Executable; 146 } 147 148 private transient EvalFactory Eval; 149 150 153 public EvalFactory Eval() { 154 if (Eval == null) { 155 Eval = new EvalFactory(this); 156 } 157 return Eval; 158 } 159 160 private transient FieldFactory Field; 161 162 165 public FieldFactory Field() { 166 if (Field == null) { 167 Field = new FieldFactory(this); 168 } 169 return Field; 170 } 171 172 175 private transient InterfaceFactory Interface; 176 177 180 public InterfaceFactory Interface() { 181 if (Interface == null) { 182 Interface = new InterfaceFactory(this); 183 } 184 return Interface; 185 } 186 187 private transient MethodFactory Method; 188 189 192 public MethodFactory Method() { 193 if (Method == null) { 194 Method = new MethodFactory(this); 195 } 196 return Method; 197 } 198 199 private PackageFactory Package; 200 201 204 public PackageFactory Package() { 205 if (Package == null) { 206 Package = new PackageFactory(this); 207 } 208 return Package; 209 } 210 211 private TemplateFactory Template; 212 213 216 public TemplateFactory Template() { 217 if (Template == null) { 218 Template = new TemplateFactory(this); 219 } 220 return Template; 221 } 222 223 private transient TypeFactory Type; 224 225 228 public TypeFactory Type() { 229 if (Type == null) { 230 Type = new TypeFactory(this); 231 } 232 return Type; 233 } 234 235 private Factory() { 236 super(); 237 if (launchingFactory == null) 238 launchingFactory = this; 239 } 240 241 static Factory launchingFactory; 242 243 250 public static Factory getLauchingFactory() { 251 return launchingFactory; 252 } 253 254 257 public Factory(CoreFactory coreFactory, Environment environment) { 258 this(); 259 this.Environment = environment; 260 this.Core = coreFactory; 261 this.Core.setMainFactory(this); 262 } 263 264 private Builder builder; 265 266 269 public Builder getBuilder() { 270 return builder; 271 } 272 273 276 public void setBuilder(Builder builder) { 277 this.builder = builder; 278 } 279 280 } 281 | Popular Tags |