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