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

com.sap.cloudfoundry.client.facade.oauth2.ImmutableOauth2AccessTokenResponse Maven / Gradle / Ivy

There is a newer version: 2.56.0
Show newest version
package com.sap.cloudfoundry.client.facade.oauth2;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.immutables.value.Generated;

/**
 * Immutable implementation of {@link Oauth2AccessTokenResponse}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableOauth2AccessTokenResponse.builder()}. */ @Generated(from = "Oauth2AccessTokenResponse", generator = "Immutables") @SuppressWarnings({"all"}) @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableOauth2AccessTokenResponse implements Oauth2AccessTokenResponse { private final String accessToken; private final String tokenType; private final String idToken; private final String refreshToken; private final long expiresIn; private final String scope; private final String jti; private ImmutableOauth2AccessTokenResponse( String accessToken, String tokenType, String idToken, String refreshToken, long expiresIn, String scope, String jti) { this.accessToken = accessToken; this.tokenType = tokenType; this.idToken = idToken; this.refreshToken = refreshToken; this.expiresIn = expiresIn; this.scope = scope; this.jti = jti; } /** * @return The value of the {@code accessToken} attribute */ @JsonProperty("access_token") @Override public String getAccessToken() { return accessToken; } /** * @return The value of the {@code tokenType} attribute */ @JsonProperty("token_type") @Override public String getTokenType() { return tokenType; } /** * @return The value of the {@code idToken} attribute */ @JsonProperty("id_token") @Override public String getIdToken() { return idToken; } /** * @return The value of the {@code refreshToken} attribute */ @JsonProperty("refresh_token") @Override public String getRefreshToken() { return refreshToken; } /** * @return The value of the {@code expiresIn} attribute */ @JsonProperty("expires_in") @Override public long getExpiresIn() { return expiresIn; } /** * @return The value of the {@code scope} attribute */ @JsonProperty("scope") @Override public String getScope() { return scope; } /** * @return The value of the {@code jti} attribute */ @JsonProperty("jti") @Override public String getJti() { return jti; } /** * Copy the current immutable object by setting a value for the {@link Oauth2AccessTokenResponse#getAccessToken() accessToken} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for accessToken * @return A modified copy of the {@code this} object */ public final ImmutableOauth2AccessTokenResponse withAccessToken(String value) { String newValue = Objects.requireNonNull(value, "accessToken"); if (this.accessToken.equals(newValue)) return this; return new ImmutableOauth2AccessTokenResponse(newValue, this.tokenType, this.idToken, this.refreshToken, this.expiresIn, this.scope, this.jti); } /** * Copy the current immutable object by setting a value for the {@link Oauth2AccessTokenResponse#getTokenType() tokenType} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for tokenType * @return A modified copy of the {@code this} object */ public final ImmutableOauth2AccessTokenResponse withTokenType(String value) { String newValue = Objects.requireNonNull(value, "tokenType"); if (this.tokenType.equals(newValue)) return this; return new ImmutableOauth2AccessTokenResponse( this.accessToken, newValue, this.idToken, this.refreshToken, this.expiresIn, this.scope, this.jti); } /** * Copy the current immutable object by setting a value for the {@link Oauth2AccessTokenResponse#getIdToken() idToken} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for idToken * @return A modified copy of the {@code this} object */ public final ImmutableOauth2AccessTokenResponse withIdToken(String value) { String newValue = Objects.requireNonNull(value, "idToken"); if (this.idToken.equals(newValue)) return this; return new ImmutableOauth2AccessTokenResponse( this.accessToken, this.tokenType, newValue, this.refreshToken, this.expiresIn, this.scope, this.jti); } /** * Copy the current immutable object by setting a value for the {@link Oauth2AccessTokenResponse#getRefreshToken() refreshToken} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for refreshToken * @return A modified copy of the {@code this} object */ public final ImmutableOauth2AccessTokenResponse withRefreshToken(String value) { String newValue = Objects.requireNonNull(value, "refreshToken"); if (this.refreshToken.equals(newValue)) return this; return new ImmutableOauth2AccessTokenResponse(this.accessToken, this.tokenType, this.idToken, newValue, this.expiresIn, this.scope, this.jti); } /** * Copy the current immutable object by setting a value for the {@link Oauth2AccessTokenResponse#getExpiresIn() expiresIn} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for expiresIn * @return A modified copy of the {@code this} object */ public final ImmutableOauth2AccessTokenResponse withExpiresIn(long value) { if (this.expiresIn == value) return this; return new ImmutableOauth2AccessTokenResponse(this.accessToken, this.tokenType, this.idToken, this.refreshToken, value, this.scope, this.jti); } /** * Copy the current immutable object by setting a value for the {@link Oauth2AccessTokenResponse#getScope() scope} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for scope * @return A modified copy of the {@code this} object */ public final ImmutableOauth2AccessTokenResponse withScope(String value) { String newValue = Objects.requireNonNull(value, "scope"); if (this.scope.equals(newValue)) return this; return new ImmutableOauth2AccessTokenResponse( this.accessToken, this.tokenType, this.idToken, this.refreshToken, this.expiresIn, newValue, this.jti); } /** * Copy the current immutable object by setting a value for the {@link Oauth2AccessTokenResponse#getJti() jti} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for jti * @return A modified copy of the {@code this} object */ public final ImmutableOauth2AccessTokenResponse withJti(String value) { String newValue = Objects.requireNonNull(value, "jti"); if (this.jti.equals(newValue)) return this; return new ImmutableOauth2AccessTokenResponse( this.accessToken, this.tokenType, this.idToken, this.refreshToken, this.expiresIn, this.scope, newValue); } /** * This instance is equal to all instances of {@code ImmutableOauth2AccessTokenResponse} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(Object another) { if (this == another) return true; return another instanceof ImmutableOauth2AccessTokenResponse && equalTo(0, (ImmutableOauth2AccessTokenResponse) another); } private boolean equalTo(int synthetic, ImmutableOauth2AccessTokenResponse another) { return accessToken.equals(another.accessToken) && tokenType.equals(another.tokenType) && idToken.equals(another.idToken) && refreshToken.equals(another.refreshToken) && expiresIn == another.expiresIn && scope.equals(another.scope) && jti.equals(another.jti); } /** * Computes a hash code from attributes: {@code accessToken}, {@code tokenType}, {@code idToken}, {@code refreshToken}, {@code expiresIn}, {@code scope}, {@code jti}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + accessToken.hashCode(); h += (h << 5) + tokenType.hashCode(); h += (h << 5) + idToken.hashCode(); h += (h << 5) + refreshToken.hashCode(); h += (h << 5) + Long.hashCode(expiresIn); h += (h << 5) + scope.hashCode(); h += (h << 5) + jti.hashCode(); return h; } /** * Prints the immutable value {@code Oauth2AccessTokenResponse} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "Oauth2AccessTokenResponse{" + "accessToken=" + accessToken + ", tokenType=" + tokenType + ", idToken=" + idToken + ", refreshToken=" + refreshToken + ", expiresIn=" + expiresIn + ", scope=" + scope + ", jti=" + jti + "}"; } /** * Utility type used to correctly read immutable object from JSON representation. * @deprecated Do not use this type directly, it exists only for the Jackson-binding infrastructure */ @Generated(from = "Oauth2AccessTokenResponse", generator = "Immutables") @Deprecated @JsonDeserialize @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements Oauth2AccessTokenResponse { String accessToken; String tokenType; String idToken; String refreshToken; long expiresIn; boolean expiresInIsSet; String scope; String jti; @JsonProperty("access_token") public void setAccessToken(String accessToken) { this.accessToken = accessToken; } @JsonProperty("token_type") public void setTokenType(String tokenType) { this.tokenType = tokenType; } @JsonProperty("id_token") public void setIdToken(String idToken) { this.idToken = idToken; } @JsonProperty("refresh_token") public void setRefreshToken(String refreshToken) { this.refreshToken = refreshToken; } @JsonProperty("expires_in") public void setExpiresIn(long expiresIn) { this.expiresIn = expiresIn; this.expiresInIsSet = true; } @JsonProperty("scope") public void setScope(String scope) { this.scope = scope; } @JsonProperty("jti") public void setJti(String jti) { this.jti = jti; } @Override public String getAccessToken() { throw new UnsupportedOperationException(); } @Override public String getTokenType() { throw new UnsupportedOperationException(); } @Override public String getIdToken() { throw new UnsupportedOperationException(); } @Override public String getRefreshToken() { throw new UnsupportedOperationException(); } @Override public long getExpiresIn() { throw new UnsupportedOperationException(); } @Override public String getScope() { throw new UnsupportedOperationException(); } @Override public String getJti() { throw new UnsupportedOperationException(); } } /** * @param json A JSON-bindable data structure * @return An immutable value type * @deprecated Do not use this method directly, it exists only for the Jackson-binding infrastructure */ @Deprecated @JsonCreator(mode = JsonCreator.Mode.DELEGATING) static ImmutableOauth2AccessTokenResponse fromJson(Json json) { ImmutableOauth2AccessTokenResponse.Builder builder = ImmutableOauth2AccessTokenResponse.builder(); if (json.accessToken != null) { builder.accessToken(json.accessToken); } if (json.tokenType != null) { builder.tokenType(json.tokenType); } if (json.idToken != null) { builder.idToken(json.idToken); } if (json.refreshToken != null) { builder.refreshToken(json.refreshToken); } if (json.expiresInIsSet) { builder.expiresIn(json.expiresIn); } if (json.scope != null) { builder.scope(json.scope); } if (json.jti != null) { builder.jti(json.jti); } return builder.build(); } /** * Creates an immutable copy of a {@link Oauth2AccessTokenResponse} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param instance The instance to copy * @return A copied immutable Oauth2AccessTokenResponse instance */ public static ImmutableOauth2AccessTokenResponse copyOf(Oauth2AccessTokenResponse instance) { if (instance instanceof ImmutableOauth2AccessTokenResponse) { return (ImmutableOauth2AccessTokenResponse) instance; } return ImmutableOauth2AccessTokenResponse.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableOauth2AccessTokenResponse ImmutableOauth2AccessTokenResponse}. *

   * ImmutableOauth2AccessTokenResponse.builder()
   *    .accessToken(String) // required {@link Oauth2AccessTokenResponse#getAccessToken() accessToken}
   *    .tokenType(String) // required {@link Oauth2AccessTokenResponse#getTokenType() tokenType}
   *    .idToken(String) // required {@link Oauth2AccessTokenResponse#getIdToken() idToken}
   *    .refreshToken(String) // required {@link Oauth2AccessTokenResponse#getRefreshToken() refreshToken}
   *    .expiresIn(long) // required {@link Oauth2AccessTokenResponse#getExpiresIn() expiresIn}
   *    .scope(String) // required {@link Oauth2AccessTokenResponse#getScope() scope}
   *    .jti(String) // required {@link Oauth2AccessTokenResponse#getJti() jti}
   *    .build();
   * 
* @return A new ImmutableOauth2AccessTokenResponse builder */ public static ImmutableOauth2AccessTokenResponse.Builder builder() { return new ImmutableOauth2AccessTokenResponse.Builder(); } /** * Builds instances of type {@link ImmutableOauth2AccessTokenResponse ImmutableOauth2AccessTokenResponse}. * Initialize attributes and then invoke the {@link #build()} method to create an * immutable instance. *

{@code Builder} is not thread-safe and generally should not be stored in a field or collection, * but instead used immediately to create instances. */ @Generated(from = "Oauth2AccessTokenResponse", generator = "Immutables") public static final class Builder { private static final long INIT_BIT_ACCESS_TOKEN = 0x1L; private static final long INIT_BIT_TOKEN_TYPE = 0x2L; private static final long INIT_BIT_ID_TOKEN = 0x4L; private static final long INIT_BIT_REFRESH_TOKEN = 0x8L; private static final long INIT_BIT_EXPIRES_IN = 0x10L; private static final long INIT_BIT_SCOPE = 0x20L; private static final long INIT_BIT_JTI = 0x40L; private long initBits = 0x7fL; private String accessToken; private String tokenType; private String idToken; private String refreshToken; private long expiresIn; private String scope; private String jti; private Builder() { } /** * Fill a builder with attribute values from the provided {@code Oauth2AccessTokenResponse} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(Oauth2AccessTokenResponse instance) { Objects.requireNonNull(instance, "instance"); this.accessToken(instance.getAccessToken()); this.tokenType(instance.getTokenType()); this.idToken(instance.getIdToken()); this.refreshToken(instance.getRefreshToken()); this.expiresIn(instance.getExpiresIn()); this.scope(instance.getScope()); this.jti(instance.getJti()); return this; } /** * Initializes the value for the {@link Oauth2AccessTokenResponse#getAccessToken() accessToken} attribute. * @param accessToken The value for accessToken * @return {@code this} builder for use in a chained invocation */ @JsonProperty("access_token") public final Builder accessToken(String accessToken) { this.accessToken = Objects.requireNonNull(accessToken, "accessToken"); initBits &= ~INIT_BIT_ACCESS_TOKEN; return this; } /** * Initializes the value for the {@link Oauth2AccessTokenResponse#getTokenType() tokenType} attribute. * @param tokenType The value for tokenType * @return {@code this} builder for use in a chained invocation */ @JsonProperty("token_type") public final Builder tokenType(String tokenType) { this.tokenType = Objects.requireNonNull(tokenType, "tokenType"); initBits &= ~INIT_BIT_TOKEN_TYPE; return this; } /** * Initializes the value for the {@link Oauth2AccessTokenResponse#getIdToken() idToken} attribute. * @param idToken The value for idToken * @return {@code this} builder for use in a chained invocation */ @JsonProperty("id_token") public final Builder idToken(String idToken) { this.idToken = Objects.requireNonNull(idToken, "idToken"); initBits &= ~INIT_BIT_ID_TOKEN; return this; } /** * Initializes the value for the {@link Oauth2AccessTokenResponse#getRefreshToken() refreshToken} attribute. * @param refreshToken The value for refreshToken * @return {@code this} builder for use in a chained invocation */ @JsonProperty("refresh_token") public final Builder refreshToken(String refreshToken) { this.refreshToken = Objects.requireNonNull(refreshToken, "refreshToken"); initBits &= ~INIT_BIT_REFRESH_TOKEN; return this; } /** * Initializes the value for the {@link Oauth2AccessTokenResponse#getExpiresIn() expiresIn} attribute. * @param expiresIn The value for expiresIn * @return {@code this} builder for use in a chained invocation */ @JsonProperty("expires_in") public final Builder expiresIn(long expiresIn) { this.expiresIn = expiresIn; initBits &= ~INIT_BIT_EXPIRES_IN; return this; } /** * Initializes the value for the {@link Oauth2AccessTokenResponse#getScope() scope} attribute. * @param scope The value for scope * @return {@code this} builder for use in a chained invocation */ @JsonProperty("scope") public final Builder scope(String scope) { this.scope = Objects.requireNonNull(scope, "scope"); initBits &= ~INIT_BIT_SCOPE; return this; } /** * Initializes the value for the {@link Oauth2AccessTokenResponse#getJti() jti} attribute. * @param jti The value for jti * @return {@code this} builder for use in a chained invocation */ @JsonProperty("jti") public final Builder jti(String jti) { this.jti = Objects.requireNonNull(jti, "jti"); initBits &= ~INIT_BIT_JTI; return this; } /** * Builds a new {@link ImmutableOauth2AccessTokenResponse ImmutableOauth2AccessTokenResponse}. * @return An immutable instance of Oauth2AccessTokenResponse * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableOauth2AccessTokenResponse build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableOauth2AccessTokenResponse(accessToken, tokenType, idToken, refreshToken, expiresIn, scope, jti); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_ACCESS_TOKEN) != 0) attributes.add("accessToken"); if ((initBits & INIT_BIT_TOKEN_TYPE) != 0) attributes.add("tokenType"); if ((initBits & INIT_BIT_ID_TOKEN) != 0) attributes.add("idToken"); if ((initBits & INIT_BIT_REFRESH_TOKEN) != 0) attributes.add("refreshToken"); if ((initBits & INIT_BIT_EXPIRES_IN) != 0) attributes.add("expiresIn"); if ((initBits & INIT_BIT_SCOPE) != 0) attributes.add("scope"); if ((initBits & INIT_BIT_JTI) != 0) attributes.add("jti"); return "Cannot build Oauth2AccessTokenResponse, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy