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.petstore.dto; 018 019import static org.apache.juneau.commons.utils.Shorts.*; 020 021import java.util.*; 022 023/** 024 * Pet domain bean. 025 * 026 * <p> 027 * Represents a pet for sale in the petstore. 028 * 029 * <h5 class='section'>See Also:</h5><ul> 030 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauPetstore">juneau-petstore</a> 031 * </ul> 032 */ 033public class Pet { 034 035 private long id; 036 private Species species; 037 private String name; 038 private float price; 039 private List<String> tags; 040 private PetStatus status; 041 private String photo; 042 043 /** 044 * Returns the pet ID. 045 * 046 * @return The pet ID. 047 */ 048 public long getId() { 049 return id; 050 } 051 052 /** 053 * Sets the pet ID. 054 * 055 * @param value The new value. 056 * @return This object. 057 */ 058 public Pet setId(long value) { 059 id = value; 060 return this; 061 } 062 063 /** 064 * Returns the species of the pet. 065 * 066 * @return The species of the pet. 067 */ 068 public Species getSpecies() { 069 return species; 070 } 071 072 /** 073 * Sets the species of the pet. 074 * 075 * @param value The new value. 076 * @return This object. 077 */ 078 public Pet setSpecies(Species value) { 079 species = value; 080 return this; 081 } 082 083 /** 084 * Returns the name of the pet. 085 * 086 * @return The name of the pet. 087 */ 088 public String getName() { 089 return name; 090 } 091 092 /** 093 * Sets the name of the pet. 094 * 095 * @param value The new value. 096 * @return This object. 097 */ 098 public Pet setName(String value) { 099 name = value; 100 return this; 101 } 102 103 /** 104 * Returns the price of the pet. 105 * 106 * @return The price of the pet. 107 */ 108 public float getPrice() { 109 return price; 110 } 111 112 /** 113 * Sets the price of the pet. 114 * 115 * @param value The new value. 116 * @return This object. 117 */ 118 public Pet setPrice(float value) { 119 price = value; 120 return this; 121 } 122 123 /** 124 * Returns the tags associated with the pet. 125 * 126 * @return The tags associated with the pet. Can be <jk>null</jk> if not set. 127 */ 128 public List<String> getTags() { 129 return u(tags); 130 } 131 132 /** 133 * Sets the tags associated with the pet. 134 * 135 * @param value The new value. Can be <jk>null</jk> to unset the property. 136 * @return This object. 137 */ 138 public Pet setTags(List<String> value) { 139 tags = cp(value); 140 return this; 141 } 142 143 /** 144 * Returns the lifecycle status of the pet. 145 * 146 * @return The lifecycle status of the pet. 147 */ 148 public PetStatus getStatus() { 149 return status; 150 } 151 152 /** 153 * Sets the lifecycle status of the pet. 154 * 155 * @param value The new value. 156 * @return This object. 157 */ 158 public Pet setStatus(PetStatus value) { 159 status = value; 160 return this; 161 } 162 163 /** 164 * Returns the URI of the pet photo. 165 * 166 * @return The URI of the pet photo. Can be <jk>null</jk> if not set. 167 */ 168 public String getPhoto() { 169 return photo; 170 } 171 172 /** 173 * Sets the URI of the pet photo. 174 * 175 * @param value The new value. Can be <jk>null</jk> to unset the property. 176 * @return This object. 177 */ 178 public Pet setPhoto(String value) { 179 photo = value; 180 return this; 181 } 182 183 /** 184 * Sets the species only if it is currently <jk>null</jk>. 185 * 186 * @param value The fallback value. 187 * @return This object. 188 */ 189 public Pet defaultSpecies(Species value) { 190 if (species == null) 191 species = value; 192 return this; 193 } 194 195 /** 196 * Sets the tags only if they are currently <jk>null</jk>. 197 * 198 * @param value The fallback value. 199 * @return This object. 200 */ 201 public Pet defaultTags(List<String> value) { 202 if (tags == null) 203 tags = cp(value); 204 return this; 205 } 206 207 /** 208 * Sets the lifecycle status only if it is currently <jk>null</jk>. 209 * 210 * @param value The fallback value. 211 * @return This object. 212 */ 213 public Pet defaultStatus(PetStatus value) { 214 if (status == null) 215 status = value; 216 return this; 217 } 218 219 /** 220 * Sets the photo URI only if it is currently <jk>null</jk>. 221 * 222 * @param value The fallback value. 223 * @return This object. 224 */ 225 public Pet defaultPhoto(String value) { 226 if (photo == null) 227 photo = value; 228 return this; 229 } 230}