1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 package edu.internet2.middleware.grouper;
34 import java.io.Serializable;
35
36 import org.apache.commons.lang.StringUtils;
37
38 import edu.internet2.middleware.grouper.app.loader.GrouperLoaderType;
39 import edu.internet2.middleware.grouper.util.GrouperUtil;
40
41
42
43
44
45
46
47 public enum FieldType implements Serializable {
48
49
50 ACCESS("access"),
51
52
53 ATTRIBUTE_DEF("attributeDef"),
54
55
56 LIST("list"),
57
58
59 NAMING("naming");
60
61
62
63
64
65
66
67 public static FieldType valueOfIgnoreCase(String type, boolean exceptionOnNull) {
68
69 FieldType fieldType = null;
70
71 try {
72 fieldType = GrouperUtil.enumValueOfIgnoreCase(FieldType.class,
73 type, false);
74 } catch (Exception e) {
75
76 }
77
78 if (fieldType != null) {
79 return fieldType;
80 }
81
82 for (FieldType localFieldType : FieldType.values()) {
83 if (StringUtils.equalsIgnoreCase(type, localFieldType.getType())) {
84 return localFieldType;
85 }
86 }
87
88 if (exceptionOnNull) {
89 throw new RuntimeException("Cant find type: " + type);
90 }
91
92 return null;
93
94 }
95
96
97
98
99
100
101 public static FieldType getInstance(String type) {
102 for (FieldType fieldType : FieldType.values()) {
103 if (StringUtils.equalsIgnoreCase(type, fieldType.getType())) {
104 return fieldType;
105 }
106 }
107 throw new RuntimeException("Cant find field type: " + type);
108 }
109
110
111
112
113
114 private FieldType(String theType) {
115 this.type = theType;
116 }
117
118
119 private String type;
120
121
122
123
124
125
126 public String toString() {
127 return this.type;
128 }
129
130
131
132
133
134 public String getType() {
135 return type;
136 }
137
138 }
139