Clover coverage report - brownies library - 1.0-beta-1 Coverage timestamp: 月 8 16 2004 17:14:42 GMT+09:00 FRAMES NO FRAMES |
file stats: | LOC: | 54 |  | Methods: | 4
| NCLOC: | 29 |  | Classes: | 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
Source file | Conditionals | Statements | Methods | TOTAL
ValuedEnum.java | 83.3% | 91.7% | 100% | 90.9% |

1 |  |
     /*
2 |  |
      * Joey and its relative products are published under the terms
3 |  |
      * of the Apache Software License.
4 |  |
      */
5 |  |
     /*
6 |  |
      * Created on 2004/01/07
7 |  |
      */
8 |  |
     package org.asyrinx.brownie.core.lang.enum;
9 |  |
10 |  |
     import java.util.Iterator;
11 |  |
     import java.util.List;
12 |  |
13 |  |
     import org.apache.commons.lang.enum.Enum;
14 |  |
15 |  |
     /**
16 |  |
      * @author akima
17 |  |
      */
18 |  |
     public class ValuedEnum extends Enum {
19 |  |
20 |  |
         /**
21 |  |
          * @param name
22 |  |
          */
23 | 12 |
         public ValuedEnum(String name, Object value) {
24 | 12 |
             super(name);
25 | 12 |
             this.value = value;
26 |  |
         }
27 |  |
28 |  |
         private final Object value;
29 |  |
30 |  |
         /**
31 |  |
          * @return
32 |  |
          */
33 | 20 |
         public Object getValue() {
34 | 20 |
             return value;
35 |  |
         }
36 |  |
37 | 3 |
         public static ValuedEnum getEnum(Class enumClass, Object value) {
38 | 3 |
             if (enumClass == null) {
39 | 0 |
                 throw new IllegalArgumentException(
40 |  |
                         "The Enum Class must not be null");
41 |  |
             }
42 | 3 |
             final List list = Enum.getEnumList(enumClass);
43 | 3 |
             for (Iterator it = list.iterator(); it.hasNext();) {
44 | 5 |
                 ValuedEnum enum = (ValuedEnum) it.next();
45 | 5 |
                 if (enum.getValue().equals(value))
46 | 2 |
                     return enum;
47 |  |
             }
48 | 1 |
             return null;
49 |  |
         }
50 |  |
51 | 6 |
         public static ValuedEnum getEnumByName(Class enumClass, String name) {
52 | 6 |
             return (ValuedEnum) Enum.getEnum(enumClass, name);
53 |  |
         }
54 |  |
     }