KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > agentis > jmi > apml > VisibilityEnum


1 package net.agentis.jmi.apml;
2
3 public final class VisibilityEnum implements Visibility {
4     public static final VisibilityEnum PRIVATE = new VisibilityEnum("private");
5     public static final VisibilityEnum PUBLIC = new VisibilityEnum("public");
6
7     private static final java.util.List JavaDoc typeName;
8     private final java.lang.String JavaDoc literalName;
9
10     static {
11         java.util.ArrayList JavaDoc temp = new java.util.ArrayList JavaDoc();
12         temp.add("APML");
13         temp.add("Visibility");
14         typeName = java.util.Collections.unmodifiableList(temp);
15     }
16
17     private VisibilityEnum(java.lang.String JavaDoc literalName) {
18         this.literalName = literalName;
19     }
20
21     public java.util.List JavaDoc refTypeName() {
22         return typeName;
23     }
24
25     public java.lang.String JavaDoc toString() {
26         return literalName;
27     }
28
29     public int hashCode() {
30         return literalName.hashCode();
31     }
32
33     public boolean equals(java.lang.Object JavaDoc o) {
34         if (o instanceof VisibilityEnum) return (o == this);
35         else if (o instanceof Visibility) return (o.toString().equals(literalName));
36         else return ((o instanceof javax.jmi.reflect.RefEnum) && ((javax.jmi.reflect.RefEnum) o).refTypeName().equals(typeName) && o.toString().equals(literalName));
37     }
38
39     public static Visibility forName(java.lang.String JavaDoc name) {
40         if (name.equals("private")) return PRIVATE;
41         if (name.equals("public")) return PUBLIC;
42         throw new java.lang.IllegalArgumentException JavaDoc("Unknown literal name '" + name + "' for enumeration 'APML.Visibility'");
43     }
44     protected java.lang.Object JavaDoc readResolve() throws java.io.ObjectStreamException JavaDoc {
45         try {
46             return forName(literalName);
47         } catch (java.lang.IllegalArgumentException JavaDoc e) {
48             throw new java.io.InvalidObjectException JavaDoc(e.getMessage());
49         }
50     }
51 }
52
Popular Tags