001    /**
002     * Copyright 2005-2011 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.rice.kew.api.action;
017    
018    import javax.xml.bind.annotation.XmlEnum;
019    import javax.xml.bind.annotation.XmlEnumValue;
020    import javax.xml.bind.annotation.XmlRootElement;
021    import javax.xml.bind.annotation.XmlType;
022    
023    import org.kuali.rice.core.api.mo.common.Coded;
024    
025    @XmlRootElement(name = "actionRequestPolicy")
026    @XmlType(name = "ActionRequestPolicyType")
027    @XmlEnum
028    public enum ActionRequestPolicy implements Coded {      
029            
030            @XmlEnumValue("F") FIRST("F", "FIRST"),
031            @XmlEnumValue("A") ALL("A", "ALL");
032            
033            private final String code;
034            private final String label;
035            
036            ActionRequestPolicy(String code, String label) {
037                    this.code = code;
038                    this.label = label;
039            }
040            
041            @Override
042            public String getCode() {
043                    return code;
044            }
045            
046            public String getLabel() {
047                    return label;
048            }
049                    
050            public static ActionRequestPolicy fromCode(String code) {
051                    if (code == null) {
052                            return null;
053                    }
054                    for (ActionRequestPolicy value : values()) {
055                            if (value.code.equals(code)) {
056                                    return value;
057                            }
058                    }
059                    throw new IllegalArgumentException("Failed to locate the ActionRequestPolicy with the given code: " + code);
060            }
061            
062    }