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

org.apache.juneau.dto.swagger.Contact Maven / Gradle / Ivy

There is a newer version: 9.0.1
Show newest version
// ***************************************************************************************************************************
// * 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.swagger;

import static org.apache.juneau.internal.BeanPropertyUtils.*;
import static org.apache.juneau.internal.StringUtils.*;

import java.net.*;
import java.net.URI;
import java.util.*;

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

/**
 * Contact information for the exposed API.
 *
 * 
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]" * } *

* *
See Also:
*
    *
*/ @Bean(properties="name,url,email,*") public class Contact extends SwaggerElement { private String name; private URI url; private String email; /** * Default constructor. */ public Contact() {} /** * Copy constructor. * * @param copyFrom The object to copy. */ public Contact(Contact copyFrom) { super(copyFrom); this.name = copyFrom.name; this.url = copyFrom.url; this.email = copyFrom.email; } /** * Make a deep copy of this object. * * @return A deep copy of this object. */ public Contact copy() { return new Contact(this); } /** * Bean property getter: name. * *

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

* 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 (for method chaining). */ public Contact setName(String value) { name = value; return this; } /** * Same as {@link #setName(String)}. * * @param value * The new value for this property. *
Non-String values will be converted to String using toString(). *
Can be null to unset the property. * @return This object (for method chaining). */ public Contact name(Object value) { return setName(toStringVal(value)); } /** * Bean property getter: url. * *

* The URL pointing to the contact information. * * @return The property value, or null if it is not set. */ public URI getUrl() { return url; } /** * Bean property setter: url. * *

* The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. *
Strings must be valid URIs. * *

* URIs defined by {@link UriResolver} can be used for values. * * @param value * The new value for this property. *
Can be null to unset the property. * @return This object (for method chaining). */ public Contact setUrl(URI value) { url = value; return this; } /** * Same as {@link #setUrl(URI)}. * * @param value * The new value for this property. *
Non-URI values will be converted to URI using new URI(value.toString()). *
Can be null to unset the property. * @return This object (for method chaining). */ public Contact url(Object value) { return setUrl(StringUtils.toURI(value)); } /** * Bean property getter: email. * *

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

* 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 (for method chaining). */ public Contact setEmail(String value) { email = value; return this; } /** * Same as {@link #setEmail(String)}. * * @param value * The new value for this property. *
Non-String values will be converted to String using toString(). *
MUST be in the format of an email address. *
Can be null to unset the property. * @return This object (for method chaining). */ public Contact email(Object value) { return setEmail(toStringVal(value)); } /** * Returns true if the name property is not null or empty. * * @return true if the name property is not null or empty. */ public boolean hasName() { return isNotEmpty(name); } /** * Returns true if the URL property is not null. * * @return true if the URL property is not null. */ public boolean hasUrl() { return url != null; } /** * Returns true if the email property is not null or empty. * * @return true if the email property is not null or empty. */ public boolean hasEmail() { return isNotEmpty(email); } @Override /* SwaggerElement */ public T get(String property, Class type) { if (property == null) return null; switch (property) { case "name": return toType(getName(), type); case "url": return toType(getUrl(), type); case "email": return toType(getEmail(), type); default: return super.get(property, type); } } @Override /* SwaggerElement */ public Contact set(String property, Object value) { if (property == null) return this; switch (property) { case "name": return name(value); case "url": return url(value); case "email": return email(value); default: super.set(property, value); return this; } } @Override /* SwaggerElement */ public Set keySet() { ASet s = new ASet() .appendIf(name != null, "name") .appendIf(url != null, "url") .appendIf(email != null, "email"); return new MultiSet<>(s, super.keySet()); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy