001package biweekly.parameter;
002
003import java.util.Collection;
004
005import biweekly.ICalVersion;
006import biweekly.component.VEvent;
007import biweekly.component.VJournal;
008import biweekly.component.VTodo;
009import biweekly.property.Attendee;
010
011/*
012 Copyright (c) 2013-2015, Michael Angstadt
013 All rights reserved.
014
015 Redistribution and use in source and binary forms, with or without
016 modification, are permitted provided that the following conditions are met: 
017
018 1. Redistributions of source code must retain the above copyright notice, this
019 list of conditions and the following disclaimer. 
020 2. Redistributions in binary form must reproduce the above copyright notice,
021 this list of conditions and the following disclaimer in the documentation
022 and/or other materials provided with the distribution. 
023
024 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
025 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
026 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
027 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
028 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
029 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
030 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
031 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
032 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
033 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
034 */
035
036/**
037 * Defines a calendar user's level of participation. Used with the
038 * {@link Attendee} property.
039 * @author Michael Angstadt
040 * @see <a href="http://tools.ietf.org/html/rfc5545#page-22">RFC 5545 p.22-3</a>
041 * @see <a href="http://www.imc.org/pdi/vcal-10.doc">vCal 1.0 p.25-6</a>
042 */
043public class ParticipationStatus extends VersionedEnumParameterValue {
044        private static final ICalParameterCaseClasses<ParticipationStatus> enums = new ICalParameterCaseClasses<ParticipationStatus>(ParticipationStatus.class);
045
046        /**
047         * Indicates that the user needs to make a decision about the item. Valid
048         * within the {@link VEvent}, {@link VTodo}, {@link VJournal} components.
049         */
050        public static final ParticipationStatus NEEDS_ACTION = new ParticipationStatus("NEEDS-ACTION");
051
052        /**
053         * Indicates that the user has accepted the item. Valid within the
054         * {@link VEvent}, {@link VTodo}, {@link VJournal} components.
055         */
056        public static final ParticipationStatus ACCEPTED = new ParticipationStatus("ACCEPTED");
057
058        /**
059         * Indicates that the user has declined the item. Valid within the
060         * {@link VEvent}, {@link VTodo}, {@link VJournal} components.
061         */
062        public static final ParticipationStatus DECLINED = new ParticipationStatus("DECLINED");
063
064        /**
065         * Indicates that the user has tentatively accepted the item. Valid within
066         * the {@link VEvent} and {@link VJournal} components.
067         */
068        public static final ParticipationStatus TENTATIVE = new ParticipationStatus("TENTATIVE");
069
070        /**
071         * Indicates that the user has delegated the item to someone else. Valid
072         * within the {@link VEvent} and {@link VTodo} components.
073         */
074        public static final ParticipationStatus DELEGATED = new ParticipationStatus("DELEGATED");
075
076        /**
077         * Indicates that the user has completed the item. Only valid within the
078         * {@link VTodo} component.
079         */
080        public static final ParticipationStatus COMPLETED = new ParticipationStatus("COMPLETED");
081
082        /**
083         * Indicates that the user is in the process of completing the item. Only
084         * valid within the {@link VTodo} component.
085         */
086        public static final ParticipationStatus IN_PROCESS = new ParticipationStatus("IN_PROCESS", ICalVersion.V2_0_DEPRECATED, ICalVersion.V2_0);
087
088        /**
089         * Indicates that the user confirmed attendance. Only valid within the
090         * {@link VEvent} component of vCalendar version 1.0.
091         */
092        public static final ParticipationStatus CONFIRMED = new ParticipationStatus("CONFIRMED", ICalVersion.V1_0);
093
094        /**
095         * Indicates that the item was sent out to the user. Valid within
096         * {@link VEvent} and {@link VTodo} components of vCalendar version 1.0.
097         */
098        public static final ParticipationStatus SENT = new ParticipationStatus("SENT", ICalVersion.V1_0);
099
100        private ParticipationStatus(String value, ICalVersion... supportedVersions) {
101                super(value, supportedVersions);
102        }
103
104        /**
105         * Searches for a parameter value that is defined as a static constant in
106         * this class.
107         * @param value the parameter value
108         * @return the object or null if not found
109         */
110        public static ParticipationStatus find(String value) {
111                if ("NEEDS ACTION".equalsIgnoreCase(value)) { //vCal
112                        return NEEDS_ACTION;
113                }
114                return enums.find(value);
115        }
116
117        /**
118         * Searches for a parameter value and creates one if it cannot be found. All
119         * objects are guaranteed to be unique, so they can be compared with
120         * {@code ==} equality.
121         * @param value the parameter value
122         * @return the object
123         */
124        public static ParticipationStatus get(String value) {
125                if ("NEEDS ACTION".equalsIgnoreCase(value)) { //vCal
126                        return NEEDS_ACTION;
127                }
128                return enums.get(value);
129        }
130
131        /**
132         * Gets all of the parameter values that are defined as static constants in
133         * this class.
134         * @return the parameter values
135         */
136        public static Collection<ParticipationStatus> all() {
137                return enums.all();
138        }
139}