Coverage Report - org.kuali.rice.kew.engine.node.ActivationTypeEnum
 
Classes in this File Line Coverage Branch Coverage Complexity
ActivationTypeEnum
0%
0/25
0%
0/20
3.571
 
 1  
 /*
 2  
  * Copyright 2005-2008 The Kuali Foundation
 3  
  * 
 4  
  * 
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  * 
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  * 
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.kuali.rice.kew.engine.node;
 18  
 
 19  
 import org.kuali.rice.core.api.mo.common.Coded;
 20  
 import org.kuali.rice.kew.util.KEWConstants;
 21  
 
 22  
 /**
 23  
  * Activation Type enum type which defines the two types of activation within the engine.
 24  
  * Sequential activation means that only a single request on a node will get activated at a time.
 25  
  * Parallel activation means that all requests on a node will be activated.
 26  
  * 
 27  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 28  
  */
 29  
 public final class ActivationTypeEnum implements Coded {
 30  
     /** Routing should process the associated ActionRequests in sequence */
 31  0
     public static final ActivationTypeEnum SEQUENTIAL = new ActivationTypeEnum(KEWConstants.ROUTE_LEVEL_SEQUENCE, KEWConstants.ROUTE_LEVEL_SEQUENTIAL_NAME, KEWConstants.ROUTE_LEVEL_SEQUENCE_LABEL);
 32  
     /** Routing should process the associated ActionRequests in parallel */
 33  0
     public static final ActivationTypeEnum PARALLEL = new ActivationTypeEnum(KEWConstants.ROUTE_LEVEL_PARALLEL, KEWConstants.ROUTE_LEVEL_PARALLEL_NAME, KEWConstants.ROUTE_LEVEL_PARALLEL_LABEL);
 34  
 
 35  
     private final String code;
 36  
     private final String name;
 37  
     private final String label;
 38  
 
 39  0
     private ActivationTypeEnum(String code, String name, String label) {
 40  0
         this.code = code;
 41  0
         this.name = name;
 42  0
         this.label = label;
 43  0
     }
 44  
 
 45  
     public String getCode() {
 46  0
         return code;
 47  
     }
 48  
 
 49  
     public String getName() {
 50  0
         return name;
 51  
     }
 52  
 
 53  
     public String getLabel() {
 54  0
         return label;
 55  
     }
 56  
 
 57  
     public String toString() {
 58  0
         return "[ActivationTypeEnum: code=" + code + ", name=" + name + ", label=" + label + "]";
 59  
     }
 60  
 
 61  
     /**
 62  
      * Parses the code verbatim and returns the enum type that matches that code exactly
 63  
      * @param code the activation type code
 64  
      * @return the enum type
 65  
      * @throws IllegalArgumentException if code is null, or invalid
 66  
      */
 67  
     public static ActivationTypeEnum lookupCode(String code) {
 68  0
         if (code == null) {
 69  0
             throw new IllegalArgumentException("Activation type code must be non-null");
 70  
         }
 71  0
         if (SEQUENTIAL.code.equals(code)) {
 72  0
             return SEQUENTIAL;
 73  0
         } else if (PARALLEL.code.equals(code)) {
 74  0
             return PARALLEL;
 75  
         } else {
 76  0
             throw new IllegalArgumentException("Invalid activation code: '" + code + "'");
 77  
         }
 78  
     }
 79  
 
 80  
     /**
 81  
      * Parses the string and returns the enum type whose code, name, or label
 82  
      * matches the string regardless of case
 83  
      * @param string the activation type string
 84  
      * @return the enum type
 85  
      * @throws IllegalArgumentException if string is null, or invalid
 86  
      */
 87  
     public static ActivationTypeEnum parse(String string) {
 88  0
         if (string == null) {
 89  0
             throw new IllegalArgumentException("Activation type string must be non-null");
 90  
         }
 91  0
         if (SEQUENTIAL.code.equalsIgnoreCase(string) ||
 92  
             SEQUENTIAL.name.equalsIgnoreCase(string) ||
 93  
             SEQUENTIAL.label.equalsIgnoreCase(string)) {
 94  0
             return SEQUENTIAL;
 95  0
         } else if (PARALLEL.code.equalsIgnoreCase(string) ||
 96  
             PARALLEL.name.equalsIgnoreCase(string) ||
 97  
             PARALLEL.label.equalsIgnoreCase(string)) {
 98  0
             return PARALLEL;
 99  
         } else {
 100  0
             throw new IllegalArgumentException("Invalid activation type: '" + string + "'");
 101  
         }
 102  
     }
 103  
 }