1 |
|
package org.kuali.student.common.util.spring; |
2 |
|
|
3 |
|
import java.beans.PropertyEditorSupport; |
4 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 5 |
Complexity Density: 0.71 |
|
5 |
|
public class SimpleEnumPropertyEditor extends PropertyEditorSupport { |
6 |
|
Class<? extends Enum<?>> enumClass; |
7 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
8 |
0
|
@Override... |
9 |
|
public void setAsText(String text) throws IllegalArgumentException { |
10 |
0
|
for (Object e : enumClass.getEnumConstants()) { |
11 |
0
|
if (e.toString().toUpperCase().equals(text.toUpperCase())) { |
12 |
0
|
this.setValue(e); |
13 |
|
} |
14 |
|
} |
15 |
|
} |
16 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
17 |
0
|
public SimpleEnumPropertyEditor(Class<? extends Enum<?>> enumClass) {... |
18 |
0
|
super(); |
19 |
0
|
if(enumClass==null||!enumClass.isEnum()){ |
20 |
0
|
throw new IllegalArgumentException("Must set a valid Enum Class in the constructor"); |
21 |
|
} |
22 |
0
|
this.enumClass = enumClass; |
23 |
|
} |
24 |
|
|
25 |
|
} |