001 package ezvcard.parameter; 002 003 import java.util.Collection; 004 005 import ezvcard.VCardVersion; 006 import ezvcard.property.Address; 007 import ezvcard.property.Label; 008 009 /* 010 Copyright (c) 2013, Michael Angstadt 011 All rights reserved. 012 013 Redistribution and use in source and binary forms, with or without 014 modification, are permitted provided that the following conditions are met: 015 016 1. Redistributions of source code must retain the above copyright notice, this 017 list of conditions and the following disclaimer. 018 2. Redistributions in binary form must reproduce the above copyright notice, 019 this list of conditions and the following disclaimer in the documentation 020 and/or other materials provided with the distribution. 021 022 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 023 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 024 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 025 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 026 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 027 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 028 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 029 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 030 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 031 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 032 033 The views and conclusions contained in the software and documentation are those 034 of the authors and should not be interpreted as representing official policies, 035 either expressed or implied, of the FreeBSD Project. 036 */ 037 038 /** 039 * Represents the TYPE parameter of the {@link Address} and {@link Label} 040 * properties. 041 * <p> 042 * <b>Supported versions:</b> {@code 2.1, 3.0, 4.0} 043 * </p> 044 * @author Michael Angstadt 045 */ 046 public class AddressType extends VersionedVCardParameter { 047 private static final VCardParameterCaseClasses<AddressType> enums = new VCardParameterCaseClasses<AddressType>(AddressType.class); 048 049 /** 050 * <b>Supported versions:</b> {@code 2.1, 3.0, 4.0} 051 */ 052 public static final AddressType HOME = new AddressType("home"); 053 054 /** 055 * <b>Supported versions:</b> {@code 2.1, 3.0, 4.0} 056 */ 057 public static final AddressType WORK = new AddressType("work"); 058 059 /** 060 * <b>Supported versions:</b> {@code 2.1, 3.0} 061 */ 062 public static final AddressType DOM = new AddressType("dom", VCardVersion.V2_1, VCardVersion.V3_0); 063 064 /** 065 * <b>Supported versions:</b> {@code 2.1, 3.0} 066 */ 067 public static final AddressType INTL = new AddressType("intl", VCardVersion.V2_1, VCardVersion.V3_0); 068 069 /** 070 * <b>Supported versions:</b> {@code 2.1, 3.0} 071 */ 072 public static final AddressType POSTAL = new AddressType("postal", VCardVersion.V2_1, VCardVersion.V3_0); 073 074 /** 075 * <b>Supported versions:</b> {@code 2.1, 3.0} 076 */ 077 public static final AddressType PARCEL = new AddressType("parcel", VCardVersion.V2_1, VCardVersion.V3_0); 078 079 /** 080 * <b>Supported versions:</b> {@code 2.1, 3.0} 081 */ 082 public static final AddressType PREF = new AddressType("pref", VCardVersion.V2_1, VCardVersion.V3_0); 083 084 private AddressType(String value, VCardVersion... supportedVersions) { 085 super(value, supportedVersions); 086 } 087 088 /** 089 * Searches for a parameter value that is defined as a static constant in 090 * this class. 091 * @param value the parameter value 092 * @return the object or null if not found 093 */ 094 public static AddressType find(String value) { 095 return enums.find(value); 096 } 097 098 /** 099 * Searches for a parameter value and creates one if it cannot be found. All 100 * objects are guaranteed to be unique, so they can be compared with 101 * {@code ==} equality. 102 * @param value the parameter value 103 * @return the object 104 */ 105 public static AddressType get(String value) { 106 return enums.get(value); 107 } 108 109 /** 110 * Gets all of the parameter values that are defined as static constants in 111 * this class. 112 * @return the parameter values 113 */ 114 public static Collection<AddressType> all() { 115 return enums.all(); 116 } 117 }