001/** 002 * Copyright 2005-2016 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 */ 016package org.kuali.rice.kew.api.action; 017 018import javax.xml.bind.annotation.XmlEnum; 019import javax.xml.bind.annotation.XmlEnumValue; 020import javax.xml.bind.annotation.XmlRootElement; 021import javax.xml.bind.annotation.XmlType; 022 023import org.kuali.rice.core.api.mo.common.Coded; 024 025@XmlRootElement(name = "recipientType") 026@XmlType(name = "RecipientTypeType") 027@XmlEnum 028public enum RecipientType implements Coded { 029 030 @XmlEnumValue("U") PRINCIPAL("U", "principal"), 031 @XmlEnumValue("W") GROUP("W", "group"), 032 @XmlEnumValue("R") ROLE("R", "role"); 033 034 private final String code; 035 private final String label; 036 037 RecipientType(String code, String label) { 038 this.code = code; 039 this.label = label; 040 } 041 042 @Override 043 public String getCode() { 044 return code; 045 } 046 047 public String getLabel() { 048 return label; 049 } 050 051 public static RecipientType fromCode(String code) { 052 if (code == null) { 053 return null; 054 } 055 for (RecipientType request : values()) { 056 if (request.code.equals(code)) { 057 return request; 058 } 059 } 060 throw new IllegalArgumentException("Failed to locate the RecipientType with the given code: " + code); 061 } 062 063}