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