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 updating {@link Pet} objects. 020 * 021 * <ul class='seealso'> 022 * <li class='extlink'>{@source} 023 * </ul> 024 */ 025@Bean(fluentSetters=true, properties="id,name,price,species,tags,photo,status") 026public class UpdatePet extends CreatePet { 027 028 @Schema(description="Pet identifier.", minimum="1") 029 private long id; 030 031 @Schema(description="Updated pet status.") 032 private PetStatus status; 033 034 /** 035 * Constructor. 036 * 037 * @param id The <bc>id</bc> property value. 038 * @param name The <bc>name</bc> property value. 039 * @param price The <bc>price</bc> property value. 040 * @param species The <bc>species</bc> property value. 041 * @param tags The <bc>tags</bc> property value. 042 * @param status The <bc>status</bc> property value. 043 * @param photo The <bc>photo</bc> property value. 044 */ 045 public UpdatePet(long id, String name, float price, Species species, String[] tags, PetStatus status, String photo) { 046 super(name, price, species, tags, photo); 047 this.id = id; 048 this.status = status; 049 } 050 051 /** 052 * Empty constructor. 053 */ 054 public UpdatePet() {} 055 056 //----------------------------------------------------------------------------------------------------------------- 057 // Bean properties 058 //----------------------------------------------------------------------------------------------------------------- 059 060 /** 061 * @return The <bc>id</jc> property value. 062 */ 063 public long getId() { 064 return id; 065 } 066 067 /** 068 * @param value The <bc>id</jc> property value. 069 * @return This object (for method chaining). 070 */ 071 public UpdatePet id(long value) { 072 this.id = value; 073 return this; 074 } 075 076 /** 077 * @return The <bc>status</jc> property value. 078 */ 079 public PetStatus getStatus() { 080 return status; 081 } 082 083 /** 084 * @param value The <bc>status</jc> property value. 085 * @return This object (for method chaining). 086 */ 087 public UpdatePet status(PetStatus value) { 088 this.status = value; 089 return this; 090 } 091 092 @Override 093 public UpdatePet name(String value) { 094 super.name(value); 095 return this; 096 } 097 098 @Override 099 public UpdatePet price(float value) { 100 super.price(value); 101 return this; 102 } 103 104 @Override 105 public UpdatePet species(Species value) { 106 super.species(value); 107 return this; 108 } 109 110 @Override 111 public UpdatePet tags(String...value) { 112 super.tags(value); 113 return this; 114 } 115 116 @Override 117 public UpdatePet photo(String value) { 118 super.photo(value); 119 return this; 120 } 121 122 //----------------------------------------------------------------------------------------------------------------- 123 // Other 124 //----------------------------------------------------------------------------------------------------------------- 125 126 public static UpdatePet example() { 127 return new UpdatePet(123, "Doggie", 9.99f, Species.DOG, new String[]{"smart","friendly"}, PetStatus.SOLD, null); 128 } 129}