Coverage Report - org.kuali.rice.krms.api.repository.LogicalOperator
 
Classes in this File Line Coverage Branch Coverage Complexity
LogicalOperator
0%
0/16
0%
0/6
2.2
LogicalOperator$Adapter
0%
0/2
N/A
2.2
 
 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.krms.api.repository;
 17  
 
 18  
 import org.kuali.rice.core.api.mo.common.Coded;
 19  
 import org.kuali.rice.core.api.util.jaxb.EnumStringAdapter;
 20  
 
 21  
 import java.util.Arrays;
 22  
 import java.util.Collection;
 23  
 import java.util.Collections;
 24  
 
 25  0
 public enum LogicalOperator implements Coded {
 26  
         
 27  0
         AND("&"),
 28  0
         OR("|");
 29  
 
 30  
         private final String code;
 31  
         
 32  0
         private LogicalOperator(String code){
 33  0
                 this.code = code;
 34  0
         }
 35  
         
 36  
         @Override
 37  
         public String getCode(){
 38  0
                 return code;
 39  
         }
 40  
         
 41  0
         public static final Collection<String> OP_CODES =
 42  
                 Collections.unmodifiableCollection(Arrays.asList(AND.code, OR.code));
 43  
                 
 44  0
     public static final Collection<String> OP_CODE_NAMES =
 45  
         Collections.unmodifiableCollection(Arrays.asList(AND.name(), OR.name()));
 46  
         
 47  
         public static LogicalOperator fromCode(String code) {
 48  0
                 if (code == null) {
 49  0
                         return null;
 50  
                 }
 51  0
                 for (LogicalOperator logicalOperator : values()) {
 52  0
                         if (logicalOperator.code.equals(code)) {
 53  0
                                 return logicalOperator;
 54  
                         }
 55  
                 }
 56  0
                 throw new IllegalArgumentException("Failed to locate the LogicalOperator with the given code: " + code);
 57  
         }
 58  
         
 59  
         @Override
 60  
         public String toString(){
 61  0
                 return code;
 62  
         }
 63  
         
 64  0
         static final class Adapter extends EnumStringAdapter<LogicalOperator> {
 65  
                 
 66  
                 protected Class<LogicalOperator> getEnumClass() {
 67  0
                         return LogicalOperator.class;
 68  
                 }
 69  
                 
 70  
         }
 71  
 
 72  
 }