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

org.cloudfoundry.client.lib.domain.ImmutableErrorDetails Maven / Gradle / Ivy

The newest version!
package org.cloudfoundry.client.lib.domain;

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.Objects;
import org.cloudfoundry.client.lib.domain.annotation.Nullable;
import org.immutables.value.Generated;

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

* Use the builder to create immutable instances: * {@code ImmutableErrorDetails.builder()}. */ @Generated(from = "ErrorDetails", generator = "Immutables") @SuppressWarnings({"all"}) @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableErrorDetails implements ErrorDetails { private final long code; private final @Nullable String description; private final @Nullable String errorCode; private ImmutableErrorDetails(ImmutableErrorDetails.Builder builder) { this.description = builder.description; this.errorCode = builder.errorCode; this.code = builder.codeIsSet() ? builder.code : ErrorDetails.super.getCode(); } private ImmutableErrorDetails( long code, @Nullable String description, @Nullable String errorCode) { this.code = code; this.description = description; this.errorCode = errorCode; } /** * @return The value of the {@code code} attribute */ @JsonProperty("code") @Override public long getCode() { return code; } /** * @return The value of the {@code description} attribute */ @JsonProperty("description") @Override public @Nullable String getDescription() { return description; } /** * @return The value of the {@code errorCode} attribute */ @JsonProperty("errorCode") @Override public @Nullable String getErrorCode() { return errorCode; } /** * Copy the current immutable object by setting a value for the {@link ErrorDetails#getCode() code} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for code * @return A modified copy of the {@code this} object */ public final ImmutableErrorDetails withCode(long value) { if (this.code == value) return this; return new ImmutableErrorDetails(value, this.description, this.errorCode); } /** * Copy the current immutable object by setting a value for the {@link ErrorDetails#getDescription() description} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for description (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableErrorDetails withDescription(@Nullable String value) { if (Objects.equals(this.description, value)) return this; return new ImmutableErrorDetails(this.code, value, this.errorCode); } /** * Copy the current immutable object by setting a value for the {@link ErrorDetails#getErrorCode() errorCode} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for errorCode (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableErrorDetails withErrorCode(@Nullable String value) { if (Objects.equals(this.errorCode, value)) return this; return new ImmutableErrorDetails(this.code, this.description, value); } /** * This instance is equal to all instances of {@code ImmutableErrorDetails} 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 ImmutableErrorDetails && equalTo((ImmutableErrorDetails) another); } private boolean equalTo(ImmutableErrorDetails another) { return code == another.code && Objects.equals(description, another.description) && Objects.equals(errorCode, another.errorCode); } /** * Computes a hash code from attributes: {@code code}, {@code description}, {@code errorCode}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + Long.hashCode(code); h += (h << 5) + Objects.hashCode(description); h += (h << 5) + Objects.hashCode(errorCode); return h; } /** * Prints the immutable value {@code ErrorDetails} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "ErrorDetails{" + "code=" + code + ", description=" + description + ", errorCode=" + errorCode + "}"; } /** * 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 = "ErrorDetails", generator = "Immutables") @Deprecated @JsonDeserialize @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements ErrorDetails { long code; boolean codeIsSet; String description; String errorCode; @JsonProperty("code") public void setCode(long code) { this.code = code; this.codeIsSet = true; } @JsonProperty("description") public void setDescription(@Nullable String description) { this.description = description; } @JsonProperty("errorCode") public void setErrorCode(@Nullable String errorCode) { this.errorCode = errorCode; } @Override public long getCode() { throw new UnsupportedOperationException(); } @Override public String getDescription() { throw new UnsupportedOperationException(); } @Override public String getErrorCode() { 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 ImmutableErrorDetails fromJson(Json json) { ImmutableErrorDetails.Builder builder = ImmutableErrorDetails.builder(); if (json.codeIsSet) { builder.code(json.code); } if (json.description != null) { builder.description(json.description); } if (json.errorCode != null) { builder.errorCode(json.errorCode); } return builder.build(); } /** * Creates an immutable copy of a {@link ErrorDetails} 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 ErrorDetails instance */ public static ImmutableErrorDetails copyOf(ErrorDetails instance) { if (instance instanceof ImmutableErrorDetails) { return (ImmutableErrorDetails) instance; } return ImmutableErrorDetails.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableErrorDetails ImmutableErrorDetails}. *

   * ImmutableErrorDetails.builder()
   *    .code(long) // optional {@link ErrorDetails#getCode() code}
   *    .description(String | null) // nullable {@link ErrorDetails#getDescription() description}
   *    .errorCode(String | null) // nullable {@link ErrorDetails#getErrorCode() errorCode}
   *    .build();
   * 
* @return A new ImmutableErrorDetails builder */ public static ImmutableErrorDetails.Builder builder() { return new ImmutableErrorDetails.Builder(); } /** * Builds instances of type {@link ImmutableErrorDetails ImmutableErrorDetails}. * 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 = "ErrorDetails", generator = "Immutables") public static final class Builder { private static final long OPT_BIT_CODE = 0x1L; private long optBits; private long code; private String description; private String errorCode; private Builder() { } /** * Fill a builder with attribute values from the provided {@code ErrorDetails} 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(ErrorDetails instance) { Objects.requireNonNull(instance, "instance"); code(instance.getCode()); @Nullable String descriptionValue = instance.getDescription(); if (descriptionValue != null) { description(descriptionValue); } @Nullable String errorCodeValue = instance.getErrorCode(); if (errorCodeValue != null) { errorCode(errorCodeValue); } return this; } /** * Initializes the value for the {@link ErrorDetails#getCode() code} attribute. *

If not set, this attribute will have a default value as returned by the initializer of {@link ErrorDetails#getCode() code}. * @param code The value for code * @return {@code this} builder for use in a chained invocation */ @JsonProperty("code") public final Builder code(long code) { this.code = code; optBits |= OPT_BIT_CODE; return this; } /** * Initializes the value for the {@link ErrorDetails#getDescription() description} attribute. * @param description The value for description (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("description") public final Builder description(@Nullable String description) { this.description = description; return this; } /** * Initializes the value for the {@link ErrorDetails#getErrorCode() errorCode} attribute. * @param errorCode The value for errorCode (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("errorCode") public final Builder errorCode(@Nullable String errorCode) { this.errorCode = errorCode; return this; } /** * Builds a new {@link ImmutableErrorDetails ImmutableErrorDetails}. * @return An immutable instance of ErrorDetails * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableErrorDetails build() { return new ImmutableErrorDetails(this); } private boolean codeIsSet() { return (optBits & OPT_BIT_CODE) != 0; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy