001    /**
002     * Copyright 2005-2013 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.kim.api.identity.personal;
017    
018    import org.kuali.rice.core.api.mo.common.Coded;
019    
020    import javax.xml.bind.annotation.XmlEnum;
021    import javax.xml.bind.annotation.XmlEnumValue;
022    import javax.xml.bind.annotation.XmlRootElement;
023    import javax.xml.bind.annotation.XmlType;
024    
025    /**
026     * A DisabilityConditionStatusCode is an enum that represents valid type indicating a disability condition status.
027     */
028    @XmlRootElement(name = "disabilityConditionStatusCodeType")
029    @XmlType(name = "disabilityConditionStatusCodeTypeType")
030    @XmlEnum
031    public enum DisabilityConditionStatusCode implements Coded {
032    
033        /**
034         * Condition type corresponding to Permanent disabilities
035         */
036        @XmlEnumValue("P") PERMANENT("P"),
037    
038        /**
039         * Condition type corresponding to Temporary disabilities
040         */
041        @XmlEnumValue("T") TEMPORARY("T");
042    
043        public final String code;
044    
045        private DisabilityConditionStatusCode(String code) {
046            this.code = code;
047        }
048    
049        @Override
050        public String getCode() {
051            return this.code;
052        }
053    
054        public static DisabilityConditionStatusCode fromCode(String code) {
055            if (code == null) {
056                return null;
057            }
058            for (DisabilityConditionStatusCode codeType : values()) {
059                if (codeType.code.equals(code)) {
060                    return codeType;
061                }
062            }
063            throw new IllegalArgumentException("Failed to locate the DisabilityConditionStatusCode with the given code: " + code);
064        }
065    
066    }
067