1
2
3
4
5 package org.sourceforge.jemm.database;
6
7 import java.io.Serializable;
8 import java.util.Collections;
9 import java.util.HashSet;
10 import java.util.Set;
11
12
13
14
15
16
17 public class EnumInfo implements Serializable {
18
19 private static final long serialVersionUID = 1L;
20
21 private final String className;
22 private final Set<String> enumValueNames;
23
24 public EnumInfo(String className,Set<String> enumValueNames) {
25 this.className = className;
26 this.enumValueNames = Collections.unmodifiableSet(new HashSet<String>(enumValueNames));
27 }
28
29 public EnumInfo(String className,String... enumValueNames) {
30 this.className = className;
31 Set<String> internalSet = new HashSet<String>();
32 for (String value : enumValueNames)
33 internalSet.add(value);
34
35 this.enumValueNames = Collections.unmodifiableSet(internalSet);
36 }
37
38 @Override
39 public int hashCode() {
40 final int prime = 31;
41 int result = 1;
42 result = prime * result + className.hashCode();
43 result = prime * result + enumValueNames.hashCode();
44 return result;
45 }
46
47 @Override
48 public boolean equals(Object obj) {
49 if (this == obj)
50 return true;
51 if (obj == null)
52 return false;
53 if (getClass() != obj.getClass())
54 return false;
55
56 EnumInfo other = (EnumInfo) obj;
57 if (!this.className.equals(other.className))
58 return false;
59 return this.enumValueNames.equals(other.enumValueNames);
60 }
61
62 public String getClassName() {
63 return className;
64 }
65
66 public Set<String> getEnumValueNames() {
67 return enumValueNames;
68 }
69 }