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 <c>atomPersonConstruct</c> 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 * & element atom:uri { atomUri }? 033 * & element atom:email { atomEmailAddress }? 034 * & extensionElement*) 035 * </p> 036 * 037 * <ul class='seealso'> 038 * <li class='link'>{@doc DtoAtom} 039 * <li class='jp'>{@doc package-summary.html#TOC} 040 * </ul> 041 */ 042public class Person extends Common { 043 044 private String name; 045 private URI uri; 046 private String email; 047 048 049 /** 050 * Normal constructor. 051 * 052 * @param name The name of the person. 053 */ 054 public Person(String name) { 055 name(name); 056 } 057 058 /** Bean constructor. */ 059 public Person() {} 060 061 062 //----------------------------------------------------------------------------------------------------------------- 063 // Bean properties 064 //----------------------------------------------------------------------------------------------------------------- 065 066 /** 067 * Returns the name of the person. 068 * 069 * @return The name of the person. 070 */ 071 public String getName() { 072 return name; 073 } 074 075 /** 076 * Sets the name of the person. 077 * 078 * @param name The name of the person. 079 * @return This object (for method chaining). 080 */ 081 @Beanp("name") 082 public Person name(String name) { 083 this.name = name; 084 return this; 085 } 086 087 /** 088 * Returns the URI of the person. 089 * 090 * @return The URI of the person. 091 */ 092 public URI getUri() { 093 return uri; 094 } 095 096 /** 097 * Sets the URI of the person. 098 * 099 * <p> 100 * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. 101 * Strings must be valid URIs. 102 * 103 * <p> 104 * URIs defined by {@link UriResolver} can be used for values. 105 * 106 * @param uri The URI of the person. 107 * @return This object (for method chaining). 108 */ 109 @Beanp("uri") 110 public Person uri(Object uri) { 111 this.uri = toURI(uri); 112 return this; 113 } 114 115 /** 116 * Returns the email address of the person. 117 * 118 * @return The email address of the person. 119 */ 120 public String getEmail() { 121 return email; 122 } 123 124 /** 125 * Sets the email address of the person. 126 * 127 * @param email The email address of the person. 128 * @return This object (for method chaining). 129 */ 130 @Beanp("email") 131 public Person email(String email) { 132 this.email = email; 133 return this; 134 } 135 136 137 //----------------------------------------------------------------------------------------------------------------- 138 // Overridden setters (to simplify method chaining) 139 //----------------------------------------------------------------------------------------------------------------- 140 141 @Override /* Common */ 142 public Person base(Object base) { 143 super.base(base); 144 return this; 145 } 146 147 @Override /* Common */ 148 public Person lang(String lang) { 149 super.lang(lang); 150 return this; 151 } 152}