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.examples.rest.petstore.dto;
014
015import org.apache.juneau.annotation.*;
016import org.apache.juneau.jsonschema.annotation.*;
017
018/**
019 * Bean for creating {@link Pet} objects.
020 *
021 * <ul class='seealso'>
022 *    <li class='extlink'>{@source}
023 * </ul>
024 */
025@Bean(fluentSetters=true, properties="name,price,species,tags,photo")
026public class CreatePet {
027
028   @Schema(description="Pet name.", minLength=3, maxLength=50)
029   private String name;
030
031   @Schema(description="Price of pet.", maximum="999.99")
032   private float price;
033
034   @Schema(description="Pet species.")
035   private Species species;
036
037   @Schema(description="Pet attributes.", example="friendly,smart")
038   private String[] tags;
039
040   @Schema(description="Photo URL.")
041   @URI
042   private String photo;
043
044   /**
045    * Constructor.
046    *
047    * @param name The <bc>name</bc> property value.
048    * @param price The <bc>price</bc> property value.
049    * @param species The <bc>species</bc> property value.
050    * @param tags The <bc>tags</bc> property value.
051    * @param photo The <bc>photo</bc> property value.
052    */
053   public CreatePet(String name, float price, Species species, String[] tags, String photo) {
054      this.name = name;
055      this.price = price;
056      this.species = species;
057      this.tags = tags;
058      this.photo = photo;
059   }
060
061   /**
062    * Empty constructor.
063    */
064   public CreatePet() {}
065
066   //-----------------------------------------------------------------------------------------------------------------
067   // Bean properties
068   //-----------------------------------------------------------------------------------------------------------------
069
070   /**
071    * @return The <bc>name</bc> property value.
072    */
073   public String getName() {
074      return name;
075   }
076
077   /**
078    * @param value The <bc>name</bc> property value.
079    * @return This object (for method chaining).
080    */
081   public CreatePet name(String value) {
082      this.name = value;
083      return this;
084   }
085
086   /**
087    * @return The <bc>price</bc> property value.
088    */
089   public float getPrice() {
090      return price;
091   }
092
093   /**
094    * @param value The <bc>price</bc> property value.
095    * @return This object (for method chaining).
096    */
097   public CreatePet price(float value) {
098      this.price = value;
099      return this;
100   }
101
102   /**
103    * @return The <bc>species</bc> property value.
104    */
105   public Species getSpecies() {
106      return species;
107   }
108
109   /**
110    * @param value The <bc>species</bc> property value.
111    * @return This object (for method chaining).
112    */
113   public CreatePet species(Species value) {
114      this.species = value;
115      return this;
116   }
117
118   /**
119    * @return The <bc>tags</bc> property value.
120    */
121   public String[] getTags() {
122      return tags;
123   }
124
125   /**
126    * @param value The <bc>tags</bc> property value.
127    * @return This object (for method chaining).
128    */
129   public CreatePet tags(String...value) {
130      this.tags = value;
131      return this;
132   }
133
134   /**
135    * @return The <bc>photo</bc> property value.
136    */
137   public String getPhoto() {
138      return photo;
139   }
140
141   /**
142    * @param value The <bc>photo</bc> property value.
143    * @return This object (for method chaining).
144    */
145   public CreatePet photo(String value) {
146      this.photo = value;
147      return this;
148   }
149
150   //-----------------------------------------------------------------------------------------------------------------
151   // Other
152   //-----------------------------------------------------------------------------------------------------------------
153
154   /**
155    * @return An example POJO.
156    */
157   public static CreatePet example() {
158      return new CreatePet("Doggie", 9.99f, Species.DOG, new String[]{"smart","friendly"}, null);
159   }
160}