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

org.apache.juneau.dto.openapi3.Link 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.LinkedHashMap;
import java.util.Map;
import java.util.Set;

/**
 * information for Link 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="operationRef,operationId,description,requestBody,server,parameters,*") @FluentSetters public class Link extends OpenApiElement { private String operationRef; private String operationId; private String description; private Object requestBody; private Server server; private Map parameters; /** * Default constructor. */ public Link() {} /** * Copy constructor. * * @param copyFrom The object to copy. */ public Link(Link copyFrom) { super(copyFrom); this.operationRef = copyFrom.operationRef; this.description = copyFrom.description; this.operationId = copyFrom.operationId; this.requestBody = copyFrom.requestBody; this.server = copyFrom.server == null ? null : copyFrom.server.copy(); if (copyFrom.parameters == null) this.parameters = null; else this.parameters = new LinkedHashMap<>(copyFrom.parameters); } /** * Make a deep copy of this object. * * @return A deep copy of this object. */ public Link copy() { return new Link(this); } /** * Bean property getter: operationRef. * *

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

* 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 Link setOperationRef(String value) { operationRef = 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 Link 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 getOperationId() { return operationId; } /** * 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 Link setOperationId(String value) { operationId = 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 getRequestBody() { return requestBody; } /** * 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 Link setRequestBody(Object val) { requestBody = val; return this; } /** * Bean property getter: additionalProperties. * * @return The property value, or null if it is not set. */ public Server getServer() { return server; } /** * Bean property setter: additionalProperties. * * @param value * The new value for this property. *
Can be null to unset the property. * @return This object */ public Link setServer(Server value) { server = value; return this; } /** * Bean property getter: examples. * *

* An example of the response message. * * @return The property value, or null if it is not set. */ public Map getParameters() { return parameters; } /** * Bean property setter: examples. * *

* An example of the response message. * * @param value * The new value for this property. *
Keys must be MIME-type strings. *
Can be null to unset the property. * @return This object */ public Link setParameters(Map value) { parameters = copyOf(value); return this; } /** * Adds a single value to the examples property. * * @param mimeType The mime-type string. * @param parameter The example. * @return This object */ public Link addParameter(String mimeType, Object parameter) { parameters = mapBuilder(parameters).sparse().add(mimeType, parameters).build(); 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 "operationRef": return toType(getOperationRef(), type); case "operationId": return toType(getOperationId(), type); case "requestBody": return toType(getRequestBody(), type); case "parameters": return toType(getParameters(), type); case "server": return toType(getServer(), type); default: return super.get(property, type); } } @Override /* OpenApiElement */ public Link set(String property, Object value) { if (property == null) return this; switch (property) { case "description": return setDescription(stringify(value)); case "operationId": return setOperationId(stringify(value)); case "operationRef": return setOperationRef(stringify(value)); case "requestBody": return setRequestBody(value); case "server": return setServer(toType(value, Server.class)); case "parameters": return setParameters(mapBuilder(String.class,Object.class).sparse().addAny(value).build()); default: super.set(property, value); return this; } } @Override /* OpenApiElement */ public Set keySet() { Set s = setBuilder(String.class) .addIf(description != null, "description") .addIf(operationId != null, "operationId") .addIf(operationRef != null, "operationRef") .addIf(requestBody != null, "requestBody") .addIf(parameters != null, "parameters") .addIf(server != null, "server") .build(); return new MultiSet<>(s, super.keySet()); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy