![JAR search and dependency download from the Maven repository](/logo.png)
org.apache.juneau.dto.openapi3.OAuthFlow 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="authorizationUrl,tokenUrl,refreshUrl,scopes,*")
@FluentSetters
public class OAuthFlow extends OpenApiElement {
private String authorizationUrl;
private String tokenUrl;
private String refreshUrl;
private Map scopes;
/**
* Default constructor.
*/
public OAuthFlow() {}
/**
* Copy constructor.
*
* @param copyFrom The object to copy.
*/
public OAuthFlow(OAuthFlow copyFrom) {
super(copyFrom);
this.authorizationUrl = copyFrom.authorizationUrl;
this.tokenUrl = copyFrom.tokenUrl;
this.refreshUrl = copyFrom.refreshUrl;
if (copyFrom.scopes == null)
this.scopes = null;
else
this.scopes = new LinkedHashMap<>(copyFrom.scopes);
}
/**
* Make a deep copy of this object.
*
* @return A deep copy of this object.
*/
public OAuthFlow copy() {
return new OAuthFlow(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 getAuthorizationUrl() {
return authorizationUrl;
}
/**
* 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 OAuthFlow setAuthorizationUrl(String value) {
authorizationUrl = 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 getTokenUrl() {
return tokenUrl;
}
/**
* Bean property setter: description .
* @param value
* The new value for this property.
*
Can be null to unset the property.
* @return This object
*/
public OAuthFlow setTokenUrl(String value) {
tokenUrl = 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 getRefreshUrl() {
return refreshUrl;
}
/**
* 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 OAuthFlow setRefreshUrl(String value) {
refreshUrl = 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 getScopes() {
return scopes;
}
/**
* 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 OAuthFlow setScopes(Map value) {
scopes = copyOf(value);
return this;
}
/**
* Adds a single value to the examples property.
*
* @param name The mime-type string.
* @param description The example.
* @return This object
*/
public OAuthFlow addScope(String name, String description) {
scopes = mapBuilder(scopes).sparse().add(name, description).build();
return this;
}
//
//
@Override /* OpenApiElement */
public T get(String property, Class type) {
if (property == null)
return null;
switch (property) {
case "refreshUrl": return toType(getRefreshUrl(), type);
case "tokenUrl": return toType(getTokenUrl(), type);
case "authorizationUrl": return toType(getAuthorizationUrl(), type);
case "scopes": return toType(getScopes(), type);
default: return super.get(property, type);
}
}
@Override /* OpenApiElement */
public OAuthFlow set(String property, Object value) {
if (property == null)
return this;
switch (property) {
case "authorizationUrl": return setAuthorizationUrl(stringify(value));
case "tokenUrl": return setTokenUrl(stringify(value));
case "refreshUrl": return setRefreshUrl(stringify(value));
case "scopes": return setScopes(mapBuilder(String.class,String.class).sparse().addAny(value).build());
default:
super.set(property, value);
return this;
}
}
@Override /* OpenApiElement */
public Set keySet() {
Set s = setBuilder(String.class)
.addIf(authorizationUrl != null, "authorizationUrl")
.addIf(tokenUrl != null, "tokenUrl")
.addIf(refreshUrl != null, "refreshUrl")
.addIf(scopes != null, "scopes")
.build();
return new MultiSet<>(s, super.keySet());
}
}