001package ezvcard.property;
002
003import ezvcard.SupportedVersions;
004import ezvcard.VCardVersion;
005import ezvcard.parameter.HobbyLevel;
006import ezvcard.parameter.VCardParameters;
007
008/*
009 Copyright (c) 2012-2023, Michael Angstadt
010 All rights reserved.
011
012 Redistribution and use in source and binary forms, with or without
013 modification, are permitted provided that the following conditions are met: 
014
015 1. Redistributions of source code must retain the above copyright notice, this
016 list of conditions and the following disclaimer. 
017 2. Redistributions in binary form must reproduce the above copyright notice,
018 this list of conditions and the following disclaimer in the documentation
019 and/or other materials provided with the distribution. 
020
021 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
022 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
023 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
024 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
025 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
026 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
027 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
028 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
029 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
030 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
031
032 The views and conclusions contained in the software and documentation are those
033 of the authors and should not be interpreted as representing official policies, 
034 either expressed or implied, of the FreeBSD Project.
035 */
036
037/**
038 * <p>
039 * Defines a recreational activity that the person actively engages in. For
040 * example, if a person has a hobby of "hockey", it would mean that he likes to
041 * play hockey. Someone who just likes to <i>watch</i> hockey would list hockey
042 * as an {@link Interest} instead.
043 * </p>
044 * 
045 * <p>
046 * <b>Code sample</b>
047 * </p>
048 * 
049 * <pre class="brush:java">
050 * VCard vcard = new VCard();
051 * 
052 * Hobby hobby = new Hobby("hockey");
053 * hobby.setLevel(HobbyLevel.LOW);
054 * vcard.addHobby(hobby);
055 * </pre>
056 * 
057 * <p>
058 * <b>Property name:</b> {@code HOBBY}
059 * </p>
060 * <p>
061 * <b>Supported versions:</b> {@code 4.0}
062 * </p>
063 * @author Michael Angstadt
064 * @see <a href="http://tools.ietf.org/html/rfc6715#page-4">RFC 6715 p.4</a>
065 */
066@SupportedVersions(VCardVersion.V4_0)
067public class Hobby extends TextProperty implements HasAltId {
068        /**
069         * Creates a hobby property.
070         * @param hobby the hobby (e.g. "wind surfing")
071         */
072        public Hobby(String hobby) {
073                super(hobby);
074        }
075
076        /**
077         * Copy constructor.
078         * @param original the property to make a copy of
079         */
080        public Hobby(Hobby original) {
081                super(original);
082        }
083
084        /**
085         * Gets the level at which the person practices the hobby.
086         * @return the skill level (e.g. "low") or null if not set
087         * @see VCardParameters#getLevel
088         */
089        public HobbyLevel getLevel() {
090                String value = parameters.getLevel();
091                return (value == null) ? null : HobbyLevel.get(value);
092        }
093
094        /**
095         * Sets the level at which the person practices the hobby.
096         * @param level the level (e.g. "low") or null to remove
097         * @see VCardParameters#setLevel
098         */
099        public void setLevel(HobbyLevel level) {
100                parameters.setLevel(level.getValue());
101        }
102
103        @Override
104        public Integer getIndex() {
105                return super.getIndex();
106        }
107
108        @Override
109        public void setIndex(Integer index) {
110                super.setIndex(index);
111        }
112
113        /**
114         * Gets the TYPE parameter.
115         * @return the TYPE value (typically, this will be either "work" or "home")
116         * or null if it doesn't exist
117         */
118        public String getType() {
119                return parameters.getType();
120        }
121
122        /**
123         * Sets the TYPE parameter.
124         * @param type the TYPE value (this should be either "work" or "home") or
125         * null to remove
126         */
127        public void setType(String type) {
128                parameters.setType(type);
129        }
130
131        @Override
132        public String getLanguage() {
133                return super.getLanguage();
134        }
135
136        @Override
137        public void setLanguage(String language) {
138                super.setLanguage(language);
139        }
140
141        @Override
142        public Integer getPref() {
143                return super.getPref();
144        }
145
146        @Override
147        public void setPref(Integer pref) {
148                super.setPref(pref);
149        }
150
151        //@Override
152        public String getAltId() {
153                return parameters.getAltId();
154        }
155
156        //@Override
157        public void setAltId(String altId) {
158                parameters.setAltId(altId);
159        }
160
161        @Override
162        public Hobby copy() {
163                return new Hobby(this);
164        }
165}