View Javadoc

1   /**
2    * Copyright 2004-2013 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.hr.lm.leaverequest;
17  
18  
19  public enum LeaveRequestActionValue {
20      DEFER("W", "Defer"),
21      APPROVE("A", "Approve"),
22      DISAPPROVE("D", "Disapprove"),
23      NO_ACTION("", "No Action");
24  
25      public final String code;
26      public final String label;
27  
28      private LeaveRequestActionValue(String code, String label) {
29          this.code = code;
30          this.label = label;
31      }
32  
33      public String getCode() {
34          return this.code;
35      }
36  
37      public String getLabel() {
38          return this.label;
39      }
40  
41      public static LeaveRequestActionValue fromCode(String code) {
42          if (code == null) {
43              return null;
44          }
45          for (LeaveRequestActionValue type : values()) {
46              if (type.code.equals(code)) {
47                  return type;
48              }
49          }
50          throw new IllegalArgumentException("Failed to locate the LeaveRequestAction with the given code: " + code);
51      }
52  
53  }