001package ezvcard.property;
002
003import ezvcard.SupportedVersions;
004import ezvcard.VCardVersion;
005import ezvcard.parameter.InterestLevel;
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 is interested in. For
040 * example, if a person has an interest in "hockey", it would mean that he likes
041 * to watch hockey games. Someone who likes to actually <i>play</i> hockey would
042 * list hockey as a {@link Hobby} 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 * Interest interest = new Interest("hockey");
053 * interest.setLevel(InterestLevel.HIGH);
054 * vcard.addInterest(interest);
055 * </pre>
056 * 
057 * <p>
058 * <b>Property name:</b> {@code INTEREST}
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-5">RFC 6715 p.5</a>
065 */
066@SupportedVersions(VCardVersion.V4_0)
067public class Interest extends TextProperty implements HasAltId {
068        /**
069         * Creates an interest property.
070         * @param interest the hobby (e.g. "wind surfing")
071         */
072        public Interest(String interest) {
073                super(interest);
074        }
075
076        /**
077         * Copy constructor.
078         * @param original the property to make a copy of
079         */
080        public Interest(Interest original) {
081                super(original);
082        }
083
084        /**
085         * Gets the level of the person's interest.
086         * @return the interest level (e.g. "low") or null if not set
087         * @see VCardParameters#getLevel
088         */
089        public InterestLevel getLevel() {
090                String value = parameters.getLevel();
091                return (value == null) ? null : InterestLevel.get(value);
092        }
093
094        /**
095         * Sets the level of the person's interest.
096         * @param level the level (e.g. "low") or null to remove
097         * @see VCardParameters#setLevel
098         */
099        public void setLevel(InterestLevel level) {
100                String value = (level == null) ? null : level.getValue();
101                parameters.setLevel(value);
102        }
103
104        @Override
105        public Integer getIndex() {
106                return super.getIndex();
107        }
108
109        @Override
110        public void setIndex(Integer index) {
111                super.setIndex(index);
112        }
113
114        /**
115         * Gets the TYPE parameter.
116         * @return the TYPE value (typically, this will be either "work" or "home")
117         * or null if it doesn't exist
118         */
119        public String getType() {
120                return parameters.getType();
121        }
122
123        /**
124         * Sets the TYPE parameter.
125         * @param type the TYPE value (this should be either "work" or "home") or
126         * null to remove
127         */
128        public void setType(String type) {
129                parameters.setType(type);
130        }
131
132        @Override
133        public String getLanguage() {
134                return super.getLanguage();
135        }
136
137        @Override
138        public void setLanguage(String language) {
139                super.setLanguage(language);
140        }
141
142        @Override
143        public Integer getPref() {
144                return super.getPref();
145        }
146
147        @Override
148        public void setPref(Integer pref) {
149                super.setPref(pref);
150        }
151
152        //@Override
153        public String getAltId() {
154                return parameters.getAltId();
155        }
156
157        //@Override
158        public void setAltId(String altId) {
159                parameters.setAltId(altId);
160        }
161
162        @Override
163        public Interest copy() {
164                return new Interest(this);
165        }
166}