001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.dto.atom;
014
015import static org.apache.juneau.internal.StringUtils.*;
016
017import java.net.*;
018import java.net.URI;
019
020import org.apache.juneau.*;
021
022import org.apache.juneau.annotation.*;
023
024/**
025 * Represents an <code>atomPersonConstruct</code> construct in the RFC4287 specification.
026 *
027 * <h5 class='figure'>Schema</h5>
028 * <p class='bcode w800'>
029 *    atomPersonConstruct =
030 *       atomCommonAttributes,
031 *       (element atom:name { text }
032 *       &amp; element atom:uri { atomUri }?
033 *       &amp; element atom:email { atomEmailAddress }?
034 *       &amp; extensionElement*)
035 * </p>
036 *
037 * <h5 class='section'>See Also:</h5>
038 * <ul class='doctree'>
039 *    <li class='link'>{@doc juneau-dto.Atom}
040 *    <li class='jp'>{@doc package-summary.html#TOC}
041 * </ul>
042 */
043public class Person extends Common {
044
045   private String name;
046   private URI uri;
047   private String email;
048
049
050   /**
051    * Normal constructor.
052    *
053    * @param name The name of the person.
054    */
055   public Person(String name) {
056      name(name);
057   }
058
059   /** Bean constructor. */
060   public Person() {}
061
062
063   //-----------------------------------------------------------------------------------------------------------------
064   // Bean properties
065   //-----------------------------------------------------------------------------------------------------------------
066
067   /**
068    * Returns the name of the person.
069    *
070    * @return The name of the person.
071    */
072   public String getName() {
073      return name;
074   }
075
076   /**
077    * Sets the name of the person.
078    *
079    * @param name The name of the person.
080    * @return This object (for method chaining).
081    */
082   @BeanProperty("name")
083   public Person name(String name) {
084      this.name = name;
085      return this;
086   }
087
088   /**
089    * Returns the URI of the person.
090    *
091    * @return The URI of the person.
092    */
093   public URI getUri() {
094      return uri;
095   }
096
097   /**
098    * Sets the URI of the person.
099    *
100    * <p>
101    * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}.
102    * Strings must be valid URIs.
103    *
104    * <p>
105    * URIs defined by {@link UriResolver} can be used for values.
106    *
107    * @param uri The URI of the person.
108    * @return This object (for method chaining).
109    */
110   @BeanProperty("uri")
111   public Person uri(Object uri) {
112      this.uri = toURI(uri);
113      return this;
114   }
115
116   /**
117    * Returns the email address of the person.
118    *
119    * @return The email address of the person.
120    */
121   public String getEmail() {
122      return email;
123   }
124
125   /**
126    * Sets the email address of the person.
127    *
128    * @param email The email address of the person.
129    * @return This object (for method chaining).
130    */
131   @BeanProperty("email")
132   public Person email(String email) {
133      this.email = email;
134      return this;
135   }
136
137
138   //-----------------------------------------------------------------------------------------------------------------
139   // Overridden setters (to simplify method chaining)
140   //-----------------------------------------------------------------------------------------------------------------
141
142   @Override /* Common */
143   public Person base(Object base) {
144      super.base(base);
145      return this;
146   }
147
148   @Override /* Common */
149   public Person lang(String lang) {
150      super.lang(lang);
151      return this;
152   }
153}