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