All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.juneau.dto.openapi3.Example Maven / Gradle / Ivy

// ***************************************************************************************************************************
// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
// * with the License.  You may obtain a copy of the License at                                                              *
// *                                                                                                                         *
// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
// *                                                                                                                         *
// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
// * specific language governing permissions and limitations under the License.                                              *
// ***************************************************************************************************************************
package org.apache.juneau.dto.openapi3;

import static org.apache.juneau.common.internal.StringUtils.*;
import static org.apache.juneau.internal.CollectionUtils.*;
import static org.apache.juneau.internal.ConverterUtils.*;

import org.apache.juneau.annotation.Bean;
import org.apache.juneau.internal.*;

import java.util.Set;

/**
 * information for Examples object.
 *
 * 
Example:
*

* // Construct using SwaggerBuilder. * Contact x = contact("API Support", "http://www.swagger.io/support", "[email protected]"); * * // Serialize using JsonSerializer. * String json = JsonSerializer.DEFAULT.toString(x); * * // Or just use toString() which does the same as above. * String json = x.toString(); *

*

* // Output * { * "name": "API Support", * "url": "http://www.swagger.io/support", * "email": "[email protected]" * } *

*/ @Bean(properties="summary,description,externalValue,value,*") @FluentSetters public class Example extends OpenApiElement { private String summary; private String description; private String externalValue; private Object value; /** * Default constructor. */ public Example() {} /** * Copy constructor. * * @param copyFrom The object to copy. */ public Example(Example copyFrom) { super(copyFrom); this.summary = copyFrom.summary; this.description = copyFrom.description; this.externalValue = copyFrom.externalValue; this.value = copyFrom.value; } /** * Make a deep copy of this object. * * @return A deep copy of this object. */ public Example copy() { return new Example(this); } /** * Bean property getter: summary. * *

* The identifying name of the contact person/organization. * * @return The property value, or null if it is not set. */ public String getSummary() { return summary; } /** * Bean property setter: summary. * *

* The identifying name of the contact person/organization. * * @param value * The new value for this property. *
Can be null to unset the property. * @return This object */ public Example setSummary(String value) { summary = value; return this; } /** * Bean property getter: description. * *

* The URL pointing to the contact information. * * @return The property value, or null if it is not set. */ public String getDescription() { return description; } /** * Bean property setter: description. * @param value * The new value for this property. *
Can be null to unset the property. * @return This object */ public Example setDescription(String value) { description = value; return this; } /** * Bean property getter: externalValue. * *

* The email address of the contact person/organization. * * @return The property value, or null if it is not set. */ public String getExternalValue() { return externalValue; } /** * Bean property setter: externalValue. * *

* The email address of the contact person/organization. * * @param value * The new value for this property. *
MUST be in the format of an email address. *
Can be null to unset the property. * @return This object */ public Example setExternalValue(String value) { externalValue = value; return this; } /** * Bean property getter: default. * *

* Declares the value of the parameter that the server will use if none is provided, for example a "count" * to control the number of results per page might default to 100 if not supplied by the client in the request. * * (Note: "value" has no meaning for required parameters.) * Unlike JSON Schema this value MUST conform to the defined type for this parameter. * * @return The property value, or null if it is not set. */ public Object getValue() { return value; } /** * Bean property setter: value. * *

* Declares the value of the parameter that the server will use if none is provided, for example a "count" * to control the number of results per page might default to 100 if not supplied by the client in the request. * (Note: "default" has no meaning for required parameters.) * Unlike JSON Schema this value MUST conform to the defined type for this parameter. * * @param val The new value for this property. * @return This object */ public Example setValue(Object val) { value = val; return this; } // // @Override /* OpenApiElement */ public T get(String property, Class type) { if (property == null) return null; switch (property) { case "description": return toType(getDescription(), type); case "externalValue": return toType(getExternalValue(), type); case "summary": return toType(getSummary(), type); case "value": return toType(getValue(), type); default: return super.get(property, type); } } @Override /* OpenApiElement */ public Example set(String property, Object value) { if (property == null) return this; switch (property) { case "description": return setDescription(stringify(value)); case "externalValue": return setExternalValue(stringify(value)); case "summary": return setSummary(stringify(value)); case "value": return setValue(value); default: super.set(property, value); return this; } } @Override /* OpenApiElement */ public Set keySet() { Set s = setBuilder(String.class) .addIf(description != null, "description") .addIf(summary != null, "summary") .addIf(externalValue != null, "externalValue") .addIf(value != null, "value") .build(); return new MultiSet<>(s, super.keySet()); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy