Debian Codegraph @

src/main/java/ezvcard/property/Kind.java

raw symbols SCIP
1 package ezvcard.property;
2
3 import ezvcard.SupportedVersions;
4 import ezvcard.VCardVersion;
5
6 /*
7 Copyright (c) 2012-2023, Michael Angstadt
8 All rights reserved.
9
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice, this
14 list of conditions and the following disclaimer.
15 2. Redistributions in binary form must reproduce the above copyright notice,
16 this list of conditions and the following disclaimer in the documentation
17 and/or other materials provided with the distribution.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
23 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 The views and conclusions contained in the software and documentation are those
31 of the authors and should not be interpreted as representing official policies,
32 either expressed or implied, of the FreeBSD Project.
33 */
34
35 /**
36 * <p>
37 * Defines the type of entity that this vCard represents, such as an individual
38 * or an organization.
39 * </p>
40 *
41 * <p>
42 * <b>Code sample (creating)</b>
43 * </p>
44 *
45 * <pre class="brush:java">
46 * VCard vcard = new VCard();
47 *
48 * Kind kind = Kind.individual();
49 * vcard.setKind(kind);
50 * </pre>
51 *
52 * <p>
53 * <b>Code sample (retrieving)</b>
54 * </p>
55 *
56 * <pre class="brush:java">
57 * VCard vcard = ...
58 * Kind kind = vcard.getKind();
59 * if (kind.isIndividual()) {
60 * //vCard contains information on an individual person
61 * } else if (kind.isGroup()) {
62 * //vCard contains information on a group of people
63 * }
64 * //etc
65 * </pre>
66 *
67 * <p>
68 * <b>Property name:</b> {@code KIND}
69 * </p>
70 * <p>
71 * <b>Supported versions:</b> {@code 4.0}
72 * </p>
73 * @author Michael Angstadt
74 * @see <a href="http://tools.ietf.org/html/rfc6350#page-25">RFC 6350 p.25</a>
75 */
76 @SupportedVersions(VCardVersion.V4_0)
77 public class Kind extends TextProperty {
78 public static final String INDIVIDUAL = "individual";
79 public static final String GROUP = "group";
80 public static final String ORG = "org";
81 public static final String LOCATION = "location";
82 public static final String APPLICATION = "application";
83 public static final String DEVICE = "device";
84
85 /**
86 * Creates a kind property. Use of this constructor is discouraged. Please
87 * use one of the static factory methods to create a new KIND property.
88 * @param kind the kind value (e.g. "group")
89 */
90 public Kind(String kind) {
91 super(kind);
92 }
93
94 /**
95 * Copy constructor.
96 * @param original the property to make a copy of
97 */
98 public Kind(Kind original) {
99 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 }