001package ezvcard.property; 002 003import ezvcard.SupportedVersions; 004import ezvcard.VCardVersion; 005 006/* 007 Copyright (c) 2012-2018, 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", false if not 105 */ 106 public boolean isIndividual() { 107 return INDIVIDUAL.equals(value); 108 } 109 110 /** 111 * Determines if the value is set to "group". 112 * @return true if the value is "group", false if not 113 */ 114 public boolean isGroup() { 115 return GROUP.equals(value); 116 } 117 118 /** 119 * Determines if the value is set to "org". 120 * @return true if the value is "org", false if not 121 */ 122 public boolean isOrg() { 123 return ORG.equals(value); 124 } 125 126 /** 127 * Determines if the value is set to "location". 128 * @return true if the value is "location", false if not 129 */ 130 public boolean isLocation() { 131 return LOCATION.equals(value); 132 } 133 134 /** 135 * Determines if the value is set to "application". 136 * @return true if the value is "application", false if not 137 * @see <a href="http://tools.ietf.org/html/rfc6473">RFC 6473</a> 138 */ 139 public boolean isApplication() { 140 return APPLICATION.equals(value); 141 } 142 143 /** 144 * Determines if the value is set to "device". 145 * @return true if the value is "device", false if not 146 * @see <a href="http://tools.ietf.org/html/rfc6869">RFC 6869</a> 147 */ 148 public boolean isDevice() { 149 return DEVICE.equals(value); 150 } 151 152 /** 153 * Creates a new KIND property whose value is set to "individual". 154 * @return the new KIND property 155 */ 156 public static Kind individual() { 157 return new Kind(INDIVIDUAL); 158 } 159 160 /** 161 * Creates a new KIND property whose value is set to "group". 162 * @return the new KIND property 163 */ 164 public static Kind group() { 165 return new Kind(GROUP); 166 } 167 168 /** 169 * Creates a new KIND property whose value is set to "org". 170 * @return the new KIND property 171 */ 172 public static Kind org() { 173 return new Kind(ORG); 174 } 175 176 /** 177 * Creates a new KIND property whose value is set to "location". 178 * @return the new KIND property 179 */ 180 public static Kind location() { 181 return new Kind(LOCATION); 182 } 183 184 /** 185 * Creates a new KIND property whose value is set to "application". 186 * @return the new KIND property 187 * @see <a href="http://tools.ietf.org/html/rfc6473">RFC 6473</a> 188 */ 189 public static Kind application() { 190 return new Kind(APPLICATION); 191 } 192 193 /** 194 * Creates a new KIND property whose value is set to "device". 195 * @return the new KIND property 196 * @see <a href="http://tools.ietf.org/html/rfc6869">RFC 6869</a> 197 */ 198 public static Kind device() { 199 return new Kind(DEVICE); 200 } 201 202 @Override 203 public Kind copy() { 204 return new Kind(this); 205 } 206}