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

com.sap.cloudfoundry.client.facade.adapters.ImmutableRawCloudServiceBinding Maven / Gradle / Ivy

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

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.cloudfoundry.client.v3.servicebindings.ServiceBindingResource;
import org.immutables.value.Generated;

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

* Use the builder to create immutable instances: * {@code ImmutableRawCloudServiceBinding.builder()}. * Use the static factory method to create immutable instances: * {@code ImmutableRawCloudServiceBinding.of()}. */ @Generated(from = "RawCloudServiceBinding", generator = "Immutables") @SuppressWarnings({"all"}) @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableRawCloudServiceBinding extends RawCloudServiceBinding { private final ServiceBindingResource serviceBinding; private ImmutableRawCloudServiceBinding(ServiceBindingResource serviceBinding) { this.serviceBinding = Objects.requireNonNull(serviceBinding, "serviceBinding"); } private ImmutableRawCloudServiceBinding( ImmutableRawCloudServiceBinding original, ServiceBindingResource serviceBinding) { this.serviceBinding = serviceBinding; } /** * @return The value of the {@code serviceBinding} attribute */ @Override public ServiceBindingResource getServiceBinding() { return serviceBinding; } /** * Copy the current immutable object by setting a value for the {@link RawCloudServiceBinding#getServiceBinding() serviceBinding} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for serviceBinding * @return A modified copy of the {@code this} object */ public final ImmutableRawCloudServiceBinding withServiceBinding(ServiceBindingResource value) { if (this.serviceBinding == value) return this; ServiceBindingResource newValue = Objects.requireNonNull(value, "serviceBinding"); return new ImmutableRawCloudServiceBinding(this, newValue); } /** * This instance is equal to all instances of {@code ImmutableRawCloudServiceBinding} 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 ImmutableRawCloudServiceBinding && equalTo(0, (ImmutableRawCloudServiceBinding) another); } private boolean equalTo(int synthetic, ImmutableRawCloudServiceBinding another) { return serviceBinding.equals(another.serviceBinding); } /** * Computes a hash code from attributes: {@code serviceBinding}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + serviceBinding.hashCode(); return h; } /** * Prints the immutable value {@code RawCloudServiceBinding} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "RawCloudServiceBinding{" + "serviceBinding=" + serviceBinding + "}"; } /** * Construct a new immutable {@code RawCloudServiceBinding} instance. * @param serviceBinding The value for the {@code serviceBinding} attribute * @return An immutable RawCloudServiceBinding instance */ public static ImmutableRawCloudServiceBinding of(ServiceBindingResource serviceBinding) { return new ImmutableRawCloudServiceBinding(serviceBinding); } /** * Creates an immutable copy of a {@link RawCloudServiceBinding} 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 RawCloudServiceBinding instance */ public static ImmutableRawCloudServiceBinding copyOf(RawCloudServiceBinding instance) { if (instance instanceof ImmutableRawCloudServiceBinding) { return (ImmutableRawCloudServiceBinding) instance; } return ImmutableRawCloudServiceBinding.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableRawCloudServiceBinding ImmutableRawCloudServiceBinding}. *

   * ImmutableRawCloudServiceBinding.builder()
   *    .serviceBinding(org.cloudfoundry.client.v3.servicebindings.ServiceBindingResource) // required {@link RawCloudServiceBinding#getServiceBinding() serviceBinding}
   *    .build();
   * 
* @return A new ImmutableRawCloudServiceBinding builder */ public static ImmutableRawCloudServiceBinding.Builder builder() { return new ImmutableRawCloudServiceBinding.Builder(); } /** * Builds instances of type {@link ImmutableRawCloudServiceBinding ImmutableRawCloudServiceBinding}. * 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 = "RawCloudServiceBinding", generator = "Immutables") public static final class Builder { private static final long INIT_BIT_SERVICE_BINDING = 0x1L; private long initBits = 0x1L; private ServiceBindingResource serviceBinding; private Builder() { } /** * Fill a builder with attribute values from the provided {@code RawCloudServiceBinding} 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(RawCloudServiceBinding instance) { Objects.requireNonNull(instance, "instance"); this.serviceBinding(instance.getServiceBinding()); return this; } /** * Initializes the value for the {@link RawCloudServiceBinding#getServiceBinding() serviceBinding} attribute. * @param serviceBinding The value for serviceBinding * @return {@code this} builder for use in a chained invocation */ public final Builder serviceBinding(ServiceBindingResource serviceBinding) { this.serviceBinding = Objects.requireNonNull(serviceBinding, "serviceBinding"); initBits &= ~INIT_BIT_SERVICE_BINDING; return this; } /** * Builds a new {@link ImmutableRawCloudServiceBinding ImmutableRawCloudServiceBinding}. * @return An immutable instance of RawCloudServiceBinding * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableRawCloudServiceBinding build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableRawCloudServiceBinding(null, serviceBinding); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_SERVICE_BINDING) != 0) attributes.add("serviceBinding"); return "Cannot build RawCloudServiceBinding, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy