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@Bean(fluentSetters=true, properties="id,name,price,species,tags,photo,status") 022public class UpdatePet extends CreatePet { 023 024 @Schema(description="Pet identifier.", minimum="1") 025 private long id; 026 027 @Schema(description="Updated pet status.") 028 private PetStatus status; 029 030 /** 031 * Constructor. 032 */ 033 public UpdatePet(long id, String name, float price, Species species, String[] tags, PetStatus status, String photo) { 034 super(name, price, species, tags, photo); 035 this.id = id; 036 this.status = status; 037 } 038 039 /** 040 * Empty constructor. 041 */ 042 public UpdatePet() {} 043 044 //----------------------------------------------------------------------------------------------------------------- 045 // Bean properties 046 //----------------------------------------------------------------------------------------------------------------- 047 048 public long getId() { 049 return id; 050 } 051 052 public UpdatePet id(long value) { 053 this.id = value; 054 return this; 055 } 056 057 public PetStatus getStatus() { 058 return status; 059 } 060 061 public UpdatePet status(PetStatus value) { 062 this.status = value; 063 return this; 064 } 065 066 @Override 067 public UpdatePet name(String value) { 068 super.name(value); 069 return this; 070 } 071 072 @Override 073 public UpdatePet price(float value) { 074 super.price(value); 075 return this; 076 } 077 078 @Override 079 public UpdatePet species(Species value) { 080 super.species(value); 081 return this; 082 } 083 084 @Override 085 public UpdatePet tags(String...value) { 086 super.tags(value); 087 return this; 088 } 089 090 @Override 091 public UpdatePet photo(String value) { 092 super.photo(value); 093 return this; 094 } 095 096 //----------------------------------------------------------------------------------------------------------------- 097 // Other 098 //----------------------------------------------------------------------------------------------------------------- 099 100 public static UpdatePet example() { 101 return new UpdatePet(123, "Doggie", 9.99f, Species.DOG, new String[]{"smart","friendly"}, PetStatus.SOLD, null); 102 } 103}