![JAR search and dependency download from the Maven repository](/logo.png)
org.apache.juneau.dto.openapi3.License 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.UriResolver;
import org.apache.juneau.annotation.Bean;
import org.apache.juneau.internal.*;
import java.net.URI;
import java.util.Set;
/**
* License information for the exposed API.
*
* Example:
*
* // Construct using SwaggerBuilder.
* License x = license ("Apache 2.0" , "http://www.apache.org/licenses/LICENSE-2.0.html" );
*
* // 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" : "Apache 2.0" ,
* "url" : "http://www.apache.org/licenses/LICENSE-2.0.html"
* }
*
*/
@Bean(properties="name,url,*")
@FluentSetters
public class License extends OpenApiElement {
private String name;
private URI url;
/**
* Default constructor.
*/
public License() {}
/**
* Copy constructor.
*
* @param copyFrom The object to copy.
*/
public License(License copyFrom) {
super(copyFrom);
this.name = copyFrom.name;
this.url = copyFrom.url;
}
/**
* Make a deep copy of this object.
*
* @return A deep copy of this object.
*/
public License copy() {
return new License(this);
}
/**
* Bean property getter: name .
*
*
* The license name used for the API.
*
* @return The property value, or null if it is not set.
*/
public String getName() {
return name;
}
/**
* Bean property setter: name .
*
*
* The license name used for the API.
*
* @param value
* The new value for this property.
*
Property value is required.
* @return This object
*/
public License setName(String value) {
name = value;
return this;
}
/**
* Bean property getter: url .
*
*
* A URL to the license used for the API.
*
* @return The property value, or null if it is not set.
*/
public URI getUrl() {
return url;
}
/**
* Bean property setter: url .
*
*
* A URL to the license used for the API.
*
* @param value
* The new value for this property.
*
URIs defined by {@link UriResolver} can be used for values.
*
Can be null to unset the property.
* @return This object
*/
public License setUrl(URI value) {
url = value;
return this;
}
//
//
@Override /* OpenApiElement */
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);
default: return super.get(property, type);
}
}
@Override /* OpenApiElement */
public License set(String property, Object value) {
if (property == null)
return this;
switch (property) {
case "name": return setName(stringify(value));
case "url": return setUrl(toURI(value));
default:
super.set(property, value);
return this;
}
}
@Override /* OpenApiElement */
public Set keySet() {
Set s = setBuilder(String.class)
.addIf(name != null, "name")
.addIf(url != null, "url")
.build();
return new MultiSet<>(s, super.keySet());
}
}