001package biweekly.parameter;
002
003import java.util.Collection;
004
005import biweekly.ICalVersion;
006
007/*
008 Copyright (c) 2013-2015, Michael Angstadt
009 All rights reserved.
010
011 Redistribution and use in source and binary forms, with or without
012 modification, are permitted provided that the following conditions are met: 
013
014 1. Redistributions of source code must retain the above copyright notice, this
015 list of conditions and the following disclaimer. 
016 2. Redistributions in binary form must reproduce the above copyright notice,
017 this list of conditions and the following disclaimer in the documentation
018 and/or other materials provided with the distribution. 
019
020 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
021 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
022 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
023 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
024 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
025 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
026 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
027 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
028 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
029 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
030 */
031
032/**
033 * Defines the role that a calendar user holds.
034 * @author Michael Angstadt
035 * @see <a href="http://tools.ietf.org/html/rfc5545#page-25">RFC 5545 p.25-6</a>
036 * @see <a href="http://www.imc.org/pdi/vcal-10.doc">vCal 1.0 p.25</a>
037 */
038public class Role extends VersionedEnumParameterValue {
039        private static final ICalParameterCaseClasses<Role> enums = new ICalParameterCaseClasses<Role>(Role.class);
040
041        /**
042         * <p>
043         * Indicates that the user is the chair of the calendar entity.
044         * </p>
045         * <p>
046         * <b>Supported versions:</b> {@code 2.0}
047         * </p>
048         */
049        public static final Role CHAIR = new Role("CHAIR", ICalVersion.V2_0_DEPRECATED, ICalVersion.V2_0);
050
051        /**
052         * <p>
053         * Indicates that the user is an attendee of the calendar entity.
054         * </p>
055         * <p>
056         * <b>Supported versions:</b> {@code 1.0}
057         * </p>
058         */
059        public static final Role ATTENDEE = new Role("ATTENDEE", ICalVersion.V1_0);
060
061        /**
062         * <p>
063         * Indicates that the user is the organizer of the calendar entity.
064         * </p>
065         * <p>
066         * <b>Supported versions:</b> {@code 1.0}
067         * </p>
068         */
069        public static final Role ORGANIZER = new Role("ORGANIZER", ICalVersion.V1_0);
070
071        /**
072         * <p>
073         * Indicates that the user is the owner of the calendar entity.
074         * </p>
075         * <p>
076         * <b>Supported versions:</b> {@code 1.0}
077         * </p>
078         */
079        public static final Role OWNER = new Role("OWNER", ICalVersion.V1_0);
080
081        /**
082         * <p>
083         * Indicates that the user is a delegate of another attendee.
084         * </p>
085         * <p>
086         * <b>Supported versions:</b> {@code 1.0}
087         * </p>
088         */
089        public static final Role DELEGATE = new Role("DELEGATE", ICalVersion.V1_0);
090
091        private Role(String value, ICalVersion... versions) {
092                super(value, versions);
093        }
094
095        /**
096         * Searches for a parameter value that is defined as a static constant in
097         * this class.
098         * @param value the parameter value
099         * @return the object or null if not found
100         */
101        public static Role find(String value) {
102                return enums.find(value);
103        }
104
105        /**
106         * Searches for a parameter value and creates one if it cannot be found. All
107         * objects are guaranteed to be unique, so they can be compared with
108         * {@code ==} equality.
109         * @param value the parameter value
110         * @return the object
111         */
112        public static Role get(String value) {
113                return enums.get(value);
114        }
115
116        /**
117         * Gets all of the parameter values that are defined as static constants in
118         * this class.
119         * @return the parameter values
120         */
121        public static Collection<Role> all() {
122                return enums.all();
123        }
124}