Coverage Report - org.kuali.rice.kew.engine.node.ActivationTypeEnum
 
Classes in this File Line Coverage Branch Coverage Complexity
ActivationTypeEnum
0%
0/30
0%
0/28
4.429
 
 1  
 /**
 2  
  * Copyright 2005-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/ecl2.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.engine.node;
 17  
 
 18  
 import org.kuali.rice.core.api.mo.common.Coded;
 19  
 import org.kuali.rice.kew.api.KewApiConstants;
 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 implements Coded {
 29  
     /** Routing should process the associated ActionRequests in sequence */
 30  0
     public static final ActivationTypeEnum SEQUENTIAL = new ActivationTypeEnum(KewApiConstants.ROUTE_LEVEL_SEQUENCE, KewApiConstants.ROUTE_LEVEL_SEQUENTIAL_NAME, KewApiConstants.ROUTE_LEVEL_SEQUENCE_LABEL);
 31  
     /** Routing should process the associated ActionRequests in parallel */
 32  0
     public static final ActivationTypeEnum PARALLEL = new ActivationTypeEnum(KewApiConstants.ROUTE_LEVEL_PARALLEL, KewApiConstants.ROUTE_LEVEL_PARALLEL_NAME, KewApiConstants.ROUTE_LEVEL_PARALLEL_LABEL);
 33  
     /** Routing should process the associated ActionRequests in parallel according to priority */
 34  0
     public static final ActivationTypeEnum PRIORITY_PARALLEL = new ActivationTypeEnum(KewApiConstants.ROUTE_LEVEL_PRIORITY_PARALLEL, KewApiConstants.ROUTE_LEVEL_PRIORITY_PARALLEL_NAME, KewApiConstants.ROUTE_LEVEL_PRIORITY_PARALLEL_LABEL);
 35  
 
 36  
     private final String code;
 37  
     private final String name;
 38  
     private final String label;
 39  
 
 40  0
     private ActivationTypeEnum(String code, String name, String label) {
 41  0
         this.code = code;
 42  0
         this.name = name;
 43  0
         this.label = label;
 44  0
     }
 45  
 
 46  
     public String getCode() {
 47  0
         return code;
 48  
     }
 49  
 
 50  
     public String getName() {
 51  0
         return name;
 52  
     }
 53  
 
 54  
     public String getLabel() {
 55  0
         return label;
 56  
     }
 57  
 
 58  
     public String toString() {
 59  0
         return "[ActivationTypeEnum: code=" + code + ", name=" + name + ", label=" + label + "]";
 60  
     }
 61  
 
 62  
     /**
 63  
      * Parses the code verbatim and returns the enum type that matches that code exactly
 64  
      * @param code the activation type code
 65  
      * @return the enum type
 66  
      * @throws IllegalArgumentException if code is null, or invalid
 67  
      */
 68  
     public static ActivationTypeEnum lookupCode(String code) {
 69  0
         if (code == null) {
 70  0
             throw new IllegalArgumentException("Activation type code must be non-null");
 71  
         }
 72  0
         if (SEQUENTIAL.code.equals(code)) {
 73  0
             return SEQUENTIAL;
 74  0
         } else if (PARALLEL.code.equals(code)) {
 75  0
             return PARALLEL;
 76  0
         } else if (PRIORITY_PARALLEL.code.equals(code)) {
 77  0
             return PRIORITY_PARALLEL;
 78  
         } else {
 79  0
             throw new IllegalArgumentException("Invalid activation code: '" + code + "'");
 80  
         }
 81  
     }
 82  
 
 83  
     /**
 84  
      * Parses the string and returns the enum type whose code, name, or label
 85  
      * matches the string regardless of case
 86  
      * @param string the activation type string
 87  
      * @return the enum type
 88  
      * @throws IllegalArgumentException if string is null, or invalid
 89  
      */
 90  
     public static ActivationTypeEnum parse(String string) {
 91  0
         if (string == null) {
 92  0
             throw new IllegalArgumentException("Activation type string must be non-null");
 93  
         }
 94  0
         if (SEQUENTIAL.code.equalsIgnoreCase(string) ||
 95  
             SEQUENTIAL.name.equalsIgnoreCase(string) ||
 96  
             SEQUENTIAL.label.equalsIgnoreCase(string)) {
 97  0
             return SEQUENTIAL;
 98  0
         } else if (PARALLEL.code.equalsIgnoreCase(string) ||
 99  
             PARALLEL.name.equalsIgnoreCase(string) ||
 100  
             PARALLEL.label.equalsIgnoreCase(string)) {
 101  0
             return PARALLEL;
 102  0
         } else if (PRIORITY_PARALLEL.code.equalsIgnoreCase(string) ||
 103  
             PRIORITY_PARALLEL.name.equalsIgnoreCase(string) ||
 104  
             PRIORITY_PARALLEL.label.equalsIgnoreCase(string)) {
 105  0
             return PRIORITY_PARALLEL;
 106  
         } else {
 107  0
             throw new IllegalArgumentException("Invalid activation type: '" + string + "'");
 108  
         }
 109  
     }
 110  
 }