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@Bean(fluentSetters=true, properties="name,price,species,tags,photo") 022public class CreatePet { 023 024 @Schema(description="Pet name.", minLength=3, maxLength=50) 025 private String name; 026 027 @Schema(description="Price of pet.", maximum="999.99") 028 private float price; 029 030 @Schema(description="Pet species.") 031 private Species species; 032 033 @Schema(description="Pet attributes.", example="friendly,smart") 034 private String[] tags; 035 036 @Schema(description="Photo URL.") 037 @URI 038 private String photo; 039 040 /** 041 * Constructor. 042 */ 043 public CreatePet(String name, float price, Species species, String[] tags, String photo) { 044 this.name = name; 045 this.price = price; 046 this.species = species; 047 this.tags = tags; 048 this.photo = photo; 049 } 050 051 /** 052 * Empty constructor. 053 */ 054 public CreatePet() {} 055 056 //----------------------------------------------------------------------------------------------------------------- 057 // Bean properties 058 //----------------------------------------------------------------------------------------------------------------- 059 060 public String getName() { 061 return name; 062 } 063 064 public CreatePet name(String value) { 065 this.name = value; 066 return this; 067 } 068 069 public float getPrice() { 070 return price; 071 } 072 073 public CreatePet price(float value) { 074 this.price = value; 075 return this; 076 } 077 078 public Species getSpecies() { 079 return species; 080 } 081 082 public CreatePet species(Species value) { 083 this.species = value; 084 return this; 085 } 086 087 public String[] getTags() { 088 return tags; 089 } 090 091 public CreatePet tags(String...value) { 092 this.tags = value; 093 return this; 094 } 095 096 public String getPhoto() { 097 return photo; 098 } 099 100 public CreatePet photo(String photo) { 101 this.photo = photo; 102 return this; 103 } 104 105 //----------------------------------------------------------------------------------------------------------------- 106 // Other 107 //----------------------------------------------------------------------------------------------------------------- 108 109 public static CreatePet example() { 110 return new CreatePet("Doggie", 9.99f, Species.DOG, new String[]{"smart","friendly"}, null); 111 } 112}