001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.bean.atom; 018 019import static org.apache.juneau.commons.utils.StringUtils.*; 020import static org.apache.juneau.commons.utils.Utils.*; 021import static org.apache.juneau.xml.annotation.XmlFormat.*; 022 023import java.util.*; 024 025import org.apache.juneau.commons.time.*; 026import org.apache.juneau.xml.annotation.*; 027 028/** 029 * Base class for feed-level and entry-level Atom elements. 030 * 031 * <p> 032 * This abstract class contains properties common to {@link Feed}, {@link Entry}, and {@link Source} 033 * elements. These elements share a common set of metadata properties including authors, contributors, 034 * categories, links, and timestamps. 035 * 036 * <p> 037 * Common properties include: 038 * <ul class='spaced-list'> 039 * <li><b>id</b> (required) - Permanent, unique identifier 040 * <li><b>title</b> (required) - Human-readable title 041 * <li><b>updated</b> (required) - Last modification timestamp 042 * <li><b>authors</b> - Author information 043 * <li><b>categories</b> - Classification/tagging information 044 * <li><b>contributors</b> - Contributor information 045 * <li><b>links</b> - Related resources 046 * <li><b>rights</b> - Copyright/rights information 047 * </ul> 048 * 049 * <p> 050 * This class extends {@link Common}, inheriting the <c>xml:base</c> and <c>xml:lang</c> attributes. 051 * 052 * <h5 class='section'>See Also:</h5><ul> 053 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanAtom">juneau-bean-atom</a> 054 * <li class='extlink'><a class="doclink" href="https://tools.ietf.org/html/rfc4287">RFC 4287 - The Atom Syndication Format</a> 055 * </ul> 056 */ 057public class CommonEntry extends Common { 058 059 private Person[] authors; 060 private Category[] categories; 061 private Person[] contributors; 062 private Id id; 063 private Link[] links; 064 private Text rights; 065 private Text title; 066 private Calendar updated; 067 068 /** Bean constructor. */ 069 public CommonEntry() {} 070 071 /** 072 * Normal constructor. 073 * 074 * @param id The ID of this object. 075 * @param title The title of this object. 076 * @param updated The updated timestamp of this object. 077 */ 078 public CommonEntry(Id id, Text title, Calendar updated) { 079 setId(id).setTitle(title).setUpdated(updated); 080 } 081 082 /** 083 * Normal constructor. 084 * 085 * @param id The ID of this object. 086 * @param title The title of this object. 087 * @param updated The updated timestamp of this object. 088 */ 089 public CommonEntry(String id, String title, String updated) { 090 setId(id).setTitle(title).setUpdated(updated); 091 } 092 093 /** 094 * Bean property getter: <property>authors</property>. 095 * 096 * <p> 097 * The list of authors for this object. 098 * 099 * @return The property value, or <jk>null</jk> if it is not set. 100 */ 101 @Xml(format = COLLAPSED, childName = "author") 102 public Person[] getAuthors() { return authors; } 103 104 /** 105 * Bean property getter: <property>categories</property>. 106 * 107 * <p> 108 * The list of categories of this object. 109 * 110 * @return The property value, or <jk>null</jk> if it is not set. 111 */ 112 @Xml(format = COLLAPSED, childName = "category") 113 public Category[] getCategories() { return categories; } 114 115 /** 116 * Bean property getter: <property>contributors</property>. 117 * 118 * <p> 119 * The list of contributors of this object. 120 * 121 * @return The property value, or <jk>null</jk> if it is not set. 122 */ 123 @Xml(format = COLLAPSED, childName = "contributor") 124 public Person[] getContributors() { return contributors; } 125 126 /** 127 * Bean property getter: <property>id</property>. 128 * 129 * <p> 130 * The ID of this object. 131 * 132 * @return The property value, or <jk>null</jk> if it is not set. 133 */ 134 public Id getId() { return id; } 135 136 /** 137 * Bean property getter: <property>links</property>. 138 * 139 * <p> 140 * The list of links of this object. 141 * 142 * @return The property value, or <jk>null</jk> if it is not set. 143 */ 144 @Xml(format = COLLAPSED) 145 public Link[] getLinks() { return links; } 146 147 /** 148 * Bean property getter: <property>rights</property>. 149 * 150 * <p> 151 * The rights statement of this object. 152 * 153 * @return The property value, or <jk>null</jk> if it is not set. 154 */ 155 public Text getRights() { return rights; } 156 157 /** 158 * Bean property getter: <property>title</property>. 159 * 160 * <p> 161 * The title of this object. 162 * 163 * @return The property value, or <jk>null</jk> if it is not set. 164 */ 165 public Text getTitle() { return title; } 166 167 /** 168 * Bean property getter: <property>updated</property>. 169 * 170 * <p> 171 * The update timestamp of this object. 172 * 173 * @return The property value, or <jk>null</jk> if it is not set. 174 */ 175 public Calendar getUpdated() { return updated; } 176 177 /** 178 * Bean property setter: <property>authors</property>. 179 * 180 * <p> 181 * The list of authors for this object. 182 * 183 * @param value 184 * The new value for this property. 185 * <br>Can be <jk>null</jk> to unset the property. 186 * @return This object 187 */ 188 public CommonEntry setAuthors(Person...value) { 189 authors = value; 190 return this; 191 } 192 193 @Override /* Overridden from Common */ 194 public CommonEntry setBase(Object value) { 195 super.setBase(value); 196 return this; 197 } 198 199 /** 200 * Bean property setter: <property>categories</property>. 201 * 202 * <p> 203 * The list of categories of this object. 204 * 205 * @param value 206 * The new value for this property. 207 * <br>Can be <jk>null</jk> to unset the property. 208 * @return This object 209 */ 210 public CommonEntry setCategories(Category...value) { 211 categories = value; 212 return this; 213 } 214 215 /** 216 * Bean property setter: <property>contributors</property>. 217 * 218 * <p> 219 * The list of contributors of this object. 220 * 221 * @param value 222 * The new value for this property. 223 * <br>Can be <jk>null</jk> to unset the property. 224 * @return This object 225 */ 226 public CommonEntry setContributors(Person...value) { 227 contributors = value; 228 return this; 229 } 230 231 /** 232 * Bean property setter: <property>id</property>. 233 * 234 * <p> 235 * The ID of this object. 236 * 237 * @param value 238 * The new value for this property. 239 * <br>Can be <jk>null</jk> to unset the property. 240 * @return This object 241 */ 242 public CommonEntry setId(Id value) { 243 id = value; 244 return this; 245 } 246 247 /** 248 * Bean property fluent setter: <property>id</property>. 249 * 250 * <p> 251 * The ID of this object. 252 * 253 * @param value 254 * The new value for this property. 255 * <br>Can be <jk>null</jk> to unset the property. 256 * @return This object. 257 */ 258 public CommonEntry setId(String value) { 259 setId(new Id(value)); 260 return this; 261 } 262 263 @Override /* Overridden from Common */ 264 public CommonEntry setLang(String value) { 265 super.setLang(value); 266 return this; 267 } 268 269 /** 270 * Bean property setter: <property>links</property>. 271 * 272 * <p> 273 * The list of links of this object. 274 * 275 * @param value 276 * The new value for this property. 277 * <br>Can be <jk>null</jk> to unset the property. 278 * @return This object 279 */ 280 public CommonEntry setLinks(Link...value) { 281 links = value; 282 return this; 283 } 284 285 /** 286 * Bean property fluent setter: <property>rights</property>. 287 * 288 * <p> 289 * The rights statement of this object. 290 * 291 * @param value 292 * The new value for this property. 293 * <br>Can be <jk>null</jk> to unset the property. 294 * @return This object. 295 */ 296 public CommonEntry setRights(String value) { 297 setRights(new Text().setText(value)); 298 return this; 299 } 300 301 /** 302 * Bean property setter: <property>rights</property>. 303 * 304 * <p> 305 * The rights statement of this object. 306 * 307 * @param value 308 * The new value for this property. 309 * <br>Can be <jk>null</jk> to unset the property. 310 * @return This object 311 */ 312 public CommonEntry setRights(Text value) { 313 rights = value; 314 return this; 315 } 316 317 /** 318 * Bean property fluent setter: <property>title</property>. 319 * 320 * <p> 321 * The title of this object. 322 * 323 * @param value 324 * The new value for this property. 325 * <br>Can be <jk>null</jk> to unset the property. 326 * @return This object. 327 */ 328 public CommonEntry setTitle(String value) { 329 setTitle(new Text().setText(value)); 330 return this; 331 } 332 333 /** 334 * Bean property setter: <property>title</property>. 335 * 336 * <p> 337 * The title of this object. 338 * 339 * @param value 340 * The new value for this property. 341 * <br>Can be <jk>null</jk> to unset the property. 342 * @return This object 343 */ 344 public CommonEntry setTitle(Text value) { 345 title = value; 346 return this; 347 } 348 349 /** 350 * Bean property setter: <property>updated</property>. 351 * 352 * <p> 353 * The update timestamp of this object. 354 * 355 * @param value 356 * The new value for this property. 357 * <br>Can be <jk>null</jk> to unset the property. 358 * @return This object 359 */ 360 public CommonEntry setUpdated(Calendar value) { 361 updated = value; 362 return this; 363 } 364 365 /** 366 * Bean property fluent setter: <property>updated</property>. 367 * 368 * <p> 369 * The update timestamp of this object. 370 * 371 * @param value 372 * The new value for this property. 373 * <br>Can be <jk>null</jk> to unset the property. 374 * @return This object. 375 */ 376 public CommonEntry setUpdated(String value) { 377 setUpdated(opt(value).filter(x1 -> ! isBlank(x1)).map(x -> GranularZonedDateTime.of(value).getZonedDateTime()).map(GregorianCalendar::from).orElse(null)); 378 return this; 379 } 380}