Debian Codegraph @

src/main/java/ezvcard/property/Hobby.java

raw symbols SCIP
1 package ezvcard.property;
2
3 import ezvcard.SupportedVersions;
4 import ezvcard.VCardVersion;
5 import ezvcard.parameter.HobbyLevel;
6 import ezvcard.parameter.VCardParameters;
7
8 /*
9 Copyright (c) 2012-2023, Michael Angstadt
10 All rights reserved.
11
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are met:
14
15 1. Redistributions of source code must retain the above copyright notice, this
16 list of conditions and the following disclaimer.
17 2. Redistributions in binary form must reproduce the above copyright notice,
18 this list of conditions and the following disclaimer in the documentation
19 and/or other materials provided with the distribution.
20
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
25 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32 The views and conclusions contained in the software and documentation are those
33 of the authors and should not be interpreted as representing official policies,
34 either expressed or implied, of the FreeBSD Project.
35 */
36
37 /**
38 * <p>
39 * Defines a recreational activity that the person actively engages in. For
40 * example, if a person has a hobby of "hockey", it would mean that he likes to
41 * play hockey. Someone who just likes to <i>watch</i> hockey would list hockey
42 * as an {@link Interest} instead.
43 * </p>
44 *
45 * <p>
46 * <b>Code sample</b>
47 * </p>
48 *
49 * <pre class="brush:java">
50 * VCard vcard = new VCard();
51 *
52 * Hobby hobby = new Hobby("hockey");
53 * hobby.setLevel(HobbyLevel.LOW);
54 * vcard.addHobby(hobby);
55 * </pre>
56 *
57 * <p>
58 * <b>Property name:</b> {@code HOBBY}
59 * </p>
60 * <p>
61 * <b>Supported versions:</b> {@code 4.0}
62 * </p>
63 * @author Michael Angstadt
64 * @see <a href="http://tools.ietf.org/html/rfc6715#page-4">RFC 6715 p.4</a>
65 */
66 @SupportedVersions(VCardVersion.V4_0)
67 public class Hobby extends TextProperty implements HasAltId {
68 /**
69 * Creates a hobby property.
70 * @param hobby the hobby (e.g. "wind surfing")
71 */
72 public Hobby(String hobby) {
73 super(hobby);
74 }
75
76 /**
77 * Copy constructor.
78 * @param original the property to make a copy of
79 */
80 public Hobby(Hobby original) {
81 super(original);
82 }
83
84 /**
85 * Gets the level at which the person practices the hobby.
86 * @return the skill level (e.g. "low") or null if not set
87 * @see VCardParameters#getLevel
88 */
89 public HobbyLevel getLevel() {
90 String value = parameters.getLevel();
91 return (value == null) ? null : HobbyLevel.get(value);
92 }
93
94 /**
95 * Sets the level at which the person practices the hobby.
96 * @param level the level (e.g. "low") or null to remove
97 * @see VCardParameters#setLevel
98 */
99 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 }