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.kew.util.KEWConstants;
 20  
 
 21  
 /**
 22  
  * Activation Type enum type which defines the two types of activation within the engine.
 23  
  * Sequential activation means that only a single request on a node will get activated at a time.
 24  
  * Parallel activation means that all requests on a node will be activated.
 25  
  * 
 26  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 27  
  */
 28  
 public final class ActivationTypeEnum {
 29  
     /** Routing should process the associated ActionRequests in sequence */
 30  0
     public static final ActivationTypeEnum SEQUENTIAL = new ActivationTypeEnum(KEWConstants.ROUTE_LEVEL_SEQUENCE, KEWConstants.ROUTE_LEVEL_SEQUENTIAL_NAME, KEWConstants.ROUTE_LEVEL_SEQUENCE_LABEL);
 31  
     /** Routing should process the associated ActionRequests in parallel */
 32  0
     public static final ActivationTypeEnum PARALLEL = new ActivationTypeEnum(KEWConstants.ROUTE_LEVEL_PARALLEL, KEWConstants.ROUTE_LEVEL_PARALLEL_NAME, KEWConstants.ROUTE_LEVEL_PARALLEL_LABEL);
 33  
 
 34  
     private final String code;
 35  
     private final String name;
 36  
     private final String label;
 37  
 
 38  0
     private ActivationTypeEnum(String code, String name, String label) {
 39  0
         this.code = code;
 40  0
         this.name = name;
 41  0
         this.label = label;
 42  0
     }
 43  
 
 44  
     public String getCode() {
 45  0
         return code;
 46  
     }
 47  
 
 48  
     public String getName() {
 49  0
         return name;
 50  
     }
 51  
 
 52  
     public String getLabel() {
 53  0
         return label;
 54  
     }
 55  
 
 56  
     public String toString() {
 57  0
         return "[ActivationTypeEnum: code=" + code + ", name=" + name + ", label=" + label + "]";
 58  
     }
 59  
 
 60  
     /**
 61  
      * Parses the code verbatim and returns the enum type that matches that code exactly
 62  
      * @param code the activation type code
 63  
      * @return the enum type
 64  
      * @throws IllegalArgumentException if code is null, or invalid
 65  
      */
 66  
     public static ActivationTypeEnum lookupCode(String code) {
 67  0
         if (code == null) {
 68  0
             throw new IllegalArgumentException("Activation type code must be non-null");
 69  
         }
 70  0
         if (SEQUENTIAL.code.equals(code)) {
 71  0
             return SEQUENTIAL;
 72  0
         } else if (PARALLEL.code.equals(code)) {
 73  0
             return PARALLEL;
 74  
         } else {
 75  0
             throw new IllegalArgumentException("Invalid activation code: '" + code + "'");
 76  
         }
 77  
     }
 78  
 
 79  
     /**
 80  
      * Parses the string and returns the enum type whose code, name, or label
 81  
      * matches the string regardless of case
 82  
      * @param string the activation type string
 83  
      * @return the enum type
 84  
      * @throws IllegalArgumentException if string is null, or invalid
 85  
      */
 86  
     public static ActivationTypeEnum parse(String string) {
 87  0
         if (string == null) {
 88  0
             throw new IllegalArgumentException("Activation type string must be non-null");
 89  
         }
 90  0
         if (SEQUENTIAL.code.equalsIgnoreCase(string) ||
 91  
             SEQUENTIAL.name.equalsIgnoreCase(string) ||
 92  
             SEQUENTIAL.label.equalsIgnoreCase(string)) {
 93  0
             return SEQUENTIAL;
 94  0
         } else if (PARALLEL.code.equalsIgnoreCase(string) ||
 95  
             PARALLEL.name.equalsIgnoreCase(string) ||
 96  
             PARALLEL.label.equalsIgnoreCase(string)) {
 97  0
             return PARALLEL;
 98  
         } else {
 99  0
             throw new IllegalArgumentException("Invalid activation type: '" + string + "'");
 100  
         }
 101  
     }
 102  
 }