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.*; 016 017/** 018 * Bean for creating {@link Order} objects. 019 * 020 * <ul class='seealso'> 021 * <li class='extlink'>{@source} 022 * </ul> 023 */ 024@Bean(fluentSetters=true, properties="petId,username") 025public class CreateOrder { 026 027 private long petId; 028 private String username; 029 030 /** 031 * Optional constructor. 032 * 033 * @param petId The <bc>petId</bc> property value. 034 * @param username The <bc>username</bc> property value. 035 */ 036 @BeanConstructor(properties="petId,username") 037 public CreateOrder(long petId, String username) { 038 this.petId = petId; 039 this.username = username; 040 } 041 042 /** 043 * Constructor needed by JPA. 044 */ 045 public CreateOrder() {} 046 047 //----------------------------------------------------------------------------------------------------------------- 048 // Bean properties 049 //----------------------------------------------------------------------------------------------------------------- 050 051 /** 052 * @return The <bc>petId</bc> property value. 053 */ 054 public long getPetId() { 055 return petId; 056 } 057 058 /** 059 * @param value The <bc>petId</bc> property value. 060 * @return This object (for method chaining). 061 */ 062 public CreateOrder petId(long value) { 063 this.petId = value; 064 return this; 065 } 066 067 /** 068 * @return The <bc>username</bc> property value. 069 */ 070 public String getUsername() { 071 return username; 072 } 073 074 /** 075 * @param value The <bc>username</bc> property value. 076 * @return This object (for method chaining). 077 */ 078 public CreateOrder username(String value) { 079 this.username = value; 080 return this; 081 } 082 083 //----------------------------------------------------------------------------------------------------------------- 084 // Other 085 //----------------------------------------------------------------------------------------------------------------- 086 087 /** 088 * Used to populate Swagger examples. 089 * Example is inferred from the method name. 090 * 091 * @return An example POJO. 092 */ 093 public static CreateOrder example() { 094 return new CreateOrder(123, "sampleuser"); 095 } 096}