| 1 | package ezvcard.parameter; |
| 2 | |
| 3 | import static ezvcard.VCardVersion.V2_1; |
| 4 | import static ezvcard.VCardVersion.V3_0; |
| 5 | |
| 6 | import java.util.Collection; |
| 7 | |
| 8 | import ezvcard.SupportedVersions; |
| 9 | import ezvcard.property.Address; |
| 10 | import ezvcard.property.Label; |
| 11 | |
| 12 | /* |
| 13 | Copyright (c) 2012-2023, Michael Angstadt |
| 14 | All rights reserved. |
| 15 | |
| 16 | Redistribution and use in source and binary forms, with or without |
| 17 | modification, are permitted provided that the following conditions are met: |
| 18 | |
| 19 | 1. Redistributions of source code must retain the above copyright notice, this |
| 20 | list of conditions and the following disclaimer. |
| 21 | 2. Redistributions in binary form must reproduce the above copyright notice, |
| 22 | this list of conditions and the following disclaimer in the documentation |
| 23 | and/or other materials provided with the distribution. |
| 24 | |
| 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 26 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 27 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |
| 29 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 30 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 31 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 32 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 33 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 34 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 35 | |
| 36 | The views and conclusions contained in the software and documentation are those |
| 37 | of the authors and should not be interpreted as representing official policies, |
| 38 | either expressed or implied, of the FreeBSD Project. |
| 39 | */ |
| 40 | |
| 41 | /** |
| 42 | * Represents the TYPE parameter of the {@link Address} and {@link Label} |
| 43 | * properties. |
| 44 | * <p> |
| 45 | * <b>Supported versions:</b> {@code 2.1, 3.0, 4.0} |
| 46 | * </p> |
| 47 | * @author Michael Angstadt |
| 48 | */ |
| 49 | public class AddressType extends VCardParameter { |
| 50 | private static final VCardParameterCaseClasses<AddressType> enums = new VCardParameterCaseClasses<>(AddressType.class); |
| 51 | |
| 52 | public static final AddressType HOME = new AddressType("home"); |
| 53 | |
| 54 | public static final AddressType WORK = new AddressType("work"); |
| 55 | |
| 56 | @SupportedVersions({ V2_1, V3_0 }) |
| 57 | public static final AddressType DOM = new AddressType("dom"); |
| 58 | |
| 59 | @SupportedVersions({ V2_1, V3_0 }) |
| 60 | public static final AddressType INTL = new AddressType("intl"); |
| 61 | |
| 62 | @SupportedVersions({ V2_1, V3_0 }) |
| 63 | public static final AddressType POSTAL = new AddressType("postal"); |
| 64 | |
| 65 | @SupportedVersions({ V2_1, V3_0 }) |
| 66 | public static final AddressType PARCEL = new AddressType("parcel"); |
| 67 | |
| 68 | @SupportedVersions({ V2_1, V3_0 }) |
| 69 | public static final AddressType PREF = new AddressType("pref"); |
| 70 | |
| 71 | private AddressType(String value) { |
| 72 | super(value); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Searches for a parameter value that is defined as a static constant in |
| 77 | * this class. |
| 78 | * @param value the parameter value |
| 79 | * @return the object or null if not found |
| 80 | */ |
| 81 | public static AddressType find(String value) { |
| 82 | return enums.find(value); |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Searches for a parameter value and creates one if it cannot be found. All |
| 87 | * objects are guaranteed to be unique, so they can be compared with |
| 88 | * {@code ==} equality. |
| 89 | * @param value the parameter value |
| 90 | * @return the object |
| 91 | */ |
| 92 | public static AddressType get(String value) { |
| 93 | return enums.get(value); |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Gets all of the parameter values that are defined as static constants in |
| 98 | * this class. |
| 99 | * @return the parameter values |
| 100 | */ |
| 101 | public static Collection<AddressType> all() { |
| 102 | return enums.all(); |
| 103 | } |
| 104 | } |