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.kpme.tklm.leave.request;
17  
18  import org.apache.log4j.Logger;
19  import org.kuali.kpme.tklm.leave.payout.web.LeavePayoutAction;
20  
21  
22  public enum LeaveRequestActionValue {
23      DEFER("W", "Defer"),
24      APPROVE("A", "Approve"),
25      DISAPPROVE("D", "Disapprove"),
26      NO_ACTION("", "No Action");
27  
28      public final String code;
29      public final String label;
30      private static final Logger LOG = Logger.getLogger(LeaveRequestActionValue.class);
31  
32      private LeaveRequestActionValue(String code, String label) {
33          this.code = code;
34          this.label = label;
35      }
36  
37      public String getCode() {
38          return this.code;
39      }
40  
41      public String getLabel() {
42          return this.label;
43      }
44  
45      public static LeaveRequestActionValue fromCode(String code) {
46          if (code == null) {
47              return null;
48          }
49          for (LeaveRequestActionValue type : values()) {
50              if (type.code.equals(code)) {
51                  return type;
52              }
53          }
54  //        throw new IllegalArgumentException("Failed to locate the LeaveRequestAction with the given code: " + code);
55          LOG.warn("Failed to locate the LeaveRequestAction with the given code: " + code);
56          return null;
57      }
58  
59  }