Coverage Report - org.kuali.rice.kew.api.action.DelegationType
 
Classes in this File Line Coverage Branch Coverage Complexity
DelegationType
47%
9/19
12%
1/8
2.6
 
 1  
 /*
 2  
  * Copyright 2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl1.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.kew.api.action;
 17  
 
 18  
 import javax.xml.bind.annotation.XmlEnum;
 19  
 import javax.xml.bind.annotation.XmlEnumValue;
 20  
 import javax.xml.bind.annotation.XmlRootElement;
 21  
 import javax.xml.bind.annotation.XmlType;
 22  
 
 23  
 import org.kuali.rice.core.api.mo.common.Coded;
 24  
 
 25  2
 @XmlRootElement(name = "delegationType")
 26  
 @XmlType(name = "DelegationTypeType")
 27  
 @XmlEnum
 28  
 public enum DelegationType implements Coded {
 29  
 
 30  1
     @XmlEnumValue("P")
 31  
     PRIMARY("P", "Primary"),
 32  
 
 33  1
     @XmlEnumValue("S")
 34  
     SECONDARY("S", "Secondary");
 35  
 
 36  
     private final String code;
 37  
     private final String label;
 38  
 
 39  2
     DelegationType(String code, String label) {
 40  2
         this.code = code;
 41  2
         this.label = label;
 42  2
     }
 43  
 
 44  
     @Override
 45  
     public String getCode() {
 46  0
         return code;
 47  
     }
 48  
 
 49  
     public String getLabel() {
 50  0
         return label;
 51  
     }
 52  
 
 53  
     public static DelegationType fromCode(String code) {
 54  3
         if (code == null) {
 55  3
             return null;
 56  
         }
 57  0
         DelegationType value = parseCode(code);
 58  0
         if (value != null) {
 59  0
             return value;
 60  
         }
 61  0
         throw new IllegalArgumentException("Failed to locate the DelegationType with the given code: " + code);
 62  
     }
 63  
 
 64  
     public static DelegationType parseCode(String code) {
 65  0
         for (DelegationType value : values()) {
 66  0
             if (value.code.equals(code)) {
 67  0
                 return value;
 68  
             }
 69  
         }
 70  0
         return null;
 71  
     }
 72  
 }