001package ezvcard.property;
002
003import ezvcard.SupportedVersions;
004import ezvcard.VCardVersion;
005
006/*
007 Copyright (c) 2012-2023, Michael Angstadt
008 All rights reserved.
009
010 Redistribution and use in source and binary forms, with or without
011 modification, are permitted provided that the following conditions are met: 
012
013 1. Redistributions of source code must retain the above copyright notice, this
014 list of conditions and the following disclaimer. 
015 2. Redistributions in binary form must reproduce the above copyright notice,
016 this list of conditions and the following disclaimer in the documentation
017 and/or other materials provided with the distribution. 
018
019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
020 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
021 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
022 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
023 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
024 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
025 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
026 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
027 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
028 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029
030 The views and conclusions contained in the software and documentation are those
031 of the authors and should not be interpreted as representing official policies, 
032 either expressed or implied, of the FreeBSD Project.
033 */
034
035/**
036 * <p>
037 * Defines the type of entity that this vCard represents, such as an individual
038 * or an organization.
039 * </p>
040 * 
041 * <p>
042 * <b>Code sample (creating)</b>
043 * </p>
044 * 
045 * <pre class="brush:java">
046 * VCard vcard = new VCard();
047 * 
048 * Kind kind = Kind.individual();
049 * vcard.setKind(kind);
050 * </pre>
051 * 
052 * <p>
053 * <b>Code sample (retrieving)</b>
054 * </p>
055 * 
056 * <pre class="brush:java">
057 * VCard vcard = ...
058 * Kind kind = vcard.getKind();
059 * if (kind.isIndividual()) {
060 *   //vCard contains information on an individual person
061 * } else if (kind.isGroup()) {
062 *   //vCard contains information on a group of people
063 * }
064 * //etc
065 * </pre>
066 * 
067 * <p>
068 * <b>Property name:</b> {@code KIND}
069 * </p>
070 * <p>
071 * <b>Supported versions:</b> {@code 4.0}
072 * </p>
073 * @author Michael Angstadt
074 * @see <a href="http://tools.ietf.org/html/rfc6350#page-25">RFC 6350 p.25</a>
075 */
076@SupportedVersions(VCardVersion.V4_0)
077public class Kind extends TextProperty {
078        public static final String INDIVIDUAL = "individual";
079        public static final String GROUP = "group";
080        public static final String ORG = "org";
081        public static final String LOCATION = "location";
082        public static final String APPLICATION = "application";
083        public static final String DEVICE = "device";
084
085        /**
086         * Creates a kind property. Use of this constructor is discouraged. Please
087         * use one of the static factory methods to create a new KIND property.
088         * @param kind the kind value (e.g. "group")
089         */
090        public Kind(String kind) {
091                super(kind);
092        }
093
094        /**
095         * Copy constructor.
096         * @param original the property to make a copy of
097         */
098        public Kind(Kind original) {
099                super(original);
100        }
101
102        /**
103         * Determines if the value is set to "individual".
104         * @return true if the value is "individual" (case-insensitive), false if
105         * not
106         */
107        public boolean isIndividual() {
108                return INDIVIDUAL.equalsIgnoreCase(value);
109        }
110
111        /**
112         * Determines if the value is set to "group".
113         * @return true if the value is "group" (case-insensitive), false if not
114         */
115        public boolean isGroup() {
116                return GROUP.equalsIgnoreCase(value);
117        }
118
119        /**
120         * Determines if the value is set to "org".
121         * @return true if the value is "org" (case-insensitive), false if not
122         */
123        public boolean isOrg() {
124                return ORG.equalsIgnoreCase(value);
125        }
126
127        /**
128         * Determines if the value is set to "location".
129         * @return true if the value is "location" (case-insensitive), false if not
130         */
131        public boolean isLocation() {
132                return LOCATION.equalsIgnoreCase(value);
133        }
134
135        /**
136         * Determines if the value is set to "application".
137         * @return true if the value is "application" (case-insensitive), false if
138         * not
139         * @see <a href="http://tools.ietf.org/html/rfc6473">RFC 6473</a>
140         */
141        public boolean isApplication() {
142                return APPLICATION.equalsIgnoreCase(value);
143        }
144
145        /**
146         * Determines if the value is set to "device".
147         * @return true if the value is "device" (case-insensitive), false if not
148         * @see <a href="http://tools.ietf.org/html/rfc6869">RFC 6869</a>
149         */
150        public boolean isDevice() {
151                return DEVICE.equalsIgnoreCase(value);
152        }
153
154        /**
155         * Creates a new KIND property whose value is set to "individual".
156         * @return the new KIND property
157         */
158        public static Kind individual() {
159                return new Kind(INDIVIDUAL);
160        }
161
162        /**
163         * Creates a new KIND property whose value is set to "group".
164         * @return the new KIND property
165         */
166        public static Kind group() {
167                return new Kind(GROUP);
168        }
169
170        /**
171         * Creates a new KIND property whose value is set to "org".
172         * @return the new KIND property
173         */
174        public static Kind org() {
175                return new Kind(ORG);
176        }
177
178        /**
179         * Creates a new KIND property whose value is set to "location".
180         * @return the new KIND property
181         */
182        public static Kind location() {
183                return new Kind(LOCATION);
184        }
185
186        /**
187         * Creates a new KIND property whose value is set to "application".
188         * @return the new KIND property
189         * @see <a href="http://tools.ietf.org/html/rfc6473">RFC 6473</a>
190         */
191        public static Kind application() {
192                return new Kind(APPLICATION);
193        }
194
195        /**
196         * Creates a new KIND property whose value is set to "device".
197         * @return the new KIND property
198         * @see <a href="http://tools.ietf.org/html/rfc6869">RFC 6869</a>
199         */
200        public static Kind device() {
201                return new Kind(DEVICE);
202        }
203
204        @Override
205        public Kind copy() {
206                return new Kind(this);
207        }
208}