1 17 package org.apache.geronimo.kernel.repository; 18 19 import java.io.Serializable ; 20 import java.util.Map ; 21 import java.util.HashMap ; 22 23 26 public class ImportType implements Serializable { 27 private static final long serialVersionUID = 9084371394522950958L; 28 29 private static final Map typesByName = new HashMap (); 30 31 public static final ImportType ALL = new ImportType("ALL"); 33 public static final ImportType CLASSES = new ImportType("CLASSES"); 34 public static final ImportType SERVICES = new ImportType("SERVICES"); 35 36 public static Object getByName(String name) { 37 ImportType type = (ImportType) typesByName.get(name); 38 if (type == null) throw new IllegalStateException ("Unknown import type: " + name); 39 return type; 40 } 41 42 private final String name; 43 44 private ImportType(String name) { 45 this.name = name; 46 typesByName.put(name, this); 47 } 48 49 public String getName() { 50 return name; 51 } 52 53 public String toString() { 54 return name; 55 } 56 57 protected Object readResolve() { 58 String name = this.name; 59 return getByName(name); 60 } 61 } 62 | Popular Tags |