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

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

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

import com.sap.cloudfoundry.client.facade.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.cloudfoundry.client.v3.serviceinstances.ServiceInstanceResource;
import org.cloudfoundry.client.v3.serviceofferings.ServiceOffering;
import org.cloudfoundry.client.v3.serviceplans.ServicePlan;
import org.immutables.value.Generated;

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

* Use the builder to create immutable instances: * {@code ImmutableRawCloudServiceInstance.builder()}. * Use the static factory method to create immutable instances: * {@code ImmutableRawCloudServiceInstance.of()}. */ @Generated(from = "RawCloudServiceInstance", generator = "Immutables") @SuppressWarnings({"all"}) @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableRawCloudServiceInstance extends RawCloudServiceInstance { private final ServiceInstanceResource resource; private final @Nullable ServicePlan servicePlan; private final @Nullable ServiceOffering serviceOffering; private ImmutableRawCloudServiceInstance(ServiceInstanceResource resource) { this.resource = Objects.requireNonNull(resource, "resource"); this.servicePlan = null; this.serviceOffering = null; } private ImmutableRawCloudServiceInstance( ServiceInstanceResource resource, @Nullable ServicePlan servicePlan, @Nullable ServiceOffering serviceOffering) { this.resource = resource; this.servicePlan = servicePlan; this.serviceOffering = serviceOffering; } /** * @return The value of the {@code resource} attribute */ @Override public ServiceInstanceResource getResource() { return resource; } /** * @return The value of the {@code servicePlan} attribute */ @Override public @Nullable ServicePlan getServicePlan() { return servicePlan; } /** * @return The value of the {@code serviceOffering} attribute */ @Override public @Nullable ServiceOffering getServiceOffering() { return serviceOffering; } /** * Copy the current immutable object by setting a value for the {@link RawCloudServiceInstance#getResource() resource} 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 resource * @return A modified copy of the {@code this} object */ public final ImmutableRawCloudServiceInstance withResource(ServiceInstanceResource value) { if (this.resource == value) return this; ServiceInstanceResource newValue = Objects.requireNonNull(value, "resource"); return new ImmutableRawCloudServiceInstance(newValue, this.servicePlan, this.serviceOffering); } /** * Copy the current immutable object by setting a value for the {@link RawCloudServiceInstance#getServicePlan() servicePlan} 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 servicePlan (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableRawCloudServiceInstance withServicePlan(@Nullable ServicePlan value) { if (this.servicePlan == value) return this; return new ImmutableRawCloudServiceInstance(this.resource, value, this.serviceOffering); } /** * Copy the current immutable object by setting a value for the {@link RawCloudServiceInstance#getServiceOffering() serviceOffering} 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 serviceOffering (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableRawCloudServiceInstance withServiceOffering(@Nullable ServiceOffering value) { if (this.serviceOffering == value) return this; return new ImmutableRawCloudServiceInstance(this.resource, this.servicePlan, value); } /** * This instance is equal to all instances of {@code ImmutableRawCloudServiceInstance} 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 ImmutableRawCloudServiceInstance && equalTo(0, (ImmutableRawCloudServiceInstance) another); } private boolean equalTo(int synthetic, ImmutableRawCloudServiceInstance another) { return resource.equals(another.resource) && Objects.equals(servicePlan, another.servicePlan) && Objects.equals(serviceOffering, another.serviceOffering); } /** * Computes a hash code from attributes: {@code resource}, {@code servicePlan}, {@code serviceOffering}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + resource.hashCode(); h += (h << 5) + Objects.hashCode(servicePlan); h += (h << 5) + Objects.hashCode(serviceOffering); return h; } /** * Prints the immutable value {@code RawCloudServiceInstance} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "RawCloudServiceInstance{" + "resource=" + resource + ", servicePlan=" + servicePlan + ", serviceOffering=" + serviceOffering + "}"; } /** * Construct a new immutable {@code RawCloudServiceInstance} instance. * @param resource The value for the {@code resource} attribute * @return An immutable RawCloudServiceInstance instance */ public static ImmutableRawCloudServiceInstance of(ServiceInstanceResource resource) { return new ImmutableRawCloudServiceInstance(resource); } /** * Creates an immutable copy of a {@link RawCloudServiceInstance} 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 RawCloudServiceInstance instance */ public static ImmutableRawCloudServiceInstance copyOf(RawCloudServiceInstance instance) { if (instance instanceof ImmutableRawCloudServiceInstance) { return (ImmutableRawCloudServiceInstance) instance; } return ImmutableRawCloudServiceInstance.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableRawCloudServiceInstance ImmutableRawCloudServiceInstance}. *

   * ImmutableRawCloudServiceInstance.builder()
   *    .resource(org.cloudfoundry.client.v3.serviceinstances.ServiceInstanceResource) // required {@link RawCloudServiceInstance#getResource() resource}
   *    .servicePlan(org.cloudfoundry.client.v3.serviceplans.ServicePlan | null) // nullable {@link RawCloudServiceInstance#getServicePlan() servicePlan}
   *    .serviceOffering(org.cloudfoundry.client.v3.serviceofferings.ServiceOffering | null) // nullable {@link RawCloudServiceInstance#getServiceOffering() serviceOffering}
   *    .build();
   * 
* @return A new ImmutableRawCloudServiceInstance builder */ public static ImmutableRawCloudServiceInstance.Builder builder() { return new ImmutableRawCloudServiceInstance.Builder(); } /** * Builds instances of type {@link ImmutableRawCloudServiceInstance ImmutableRawCloudServiceInstance}. * 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 = "RawCloudServiceInstance", generator = "Immutables") public static final class Builder { private static final long INIT_BIT_RESOURCE = 0x1L; private long initBits = 0x1L; private ServiceInstanceResource resource; private ServicePlan servicePlan; private ServiceOffering serviceOffering; private Builder() { } /** * Fill a builder with attribute values from the provided {@code RawCloudServiceInstance} 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(RawCloudServiceInstance instance) { Objects.requireNonNull(instance, "instance"); this.resource(instance.getResource()); @Nullable ServicePlan servicePlanValue = instance.getServicePlan(); if (servicePlanValue != null) { servicePlan(servicePlanValue); } @Nullable ServiceOffering serviceOfferingValue = instance.getServiceOffering(); if (serviceOfferingValue != null) { serviceOffering(serviceOfferingValue); } return this; } /** * Initializes the value for the {@link RawCloudServiceInstance#getResource() resource} attribute. * @param resource The value for resource * @return {@code this} builder for use in a chained invocation */ public final Builder resource(ServiceInstanceResource resource) { this.resource = Objects.requireNonNull(resource, "resource"); initBits &= ~INIT_BIT_RESOURCE; return this; } /** * Initializes the value for the {@link RawCloudServiceInstance#getServicePlan() servicePlan} attribute. * @param servicePlan The value for servicePlan (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ public final Builder servicePlan(@Nullable ServicePlan servicePlan) { this.servicePlan = servicePlan; return this; } /** * Initializes the value for the {@link RawCloudServiceInstance#getServiceOffering() serviceOffering} attribute. * @param serviceOffering The value for serviceOffering (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ public final Builder serviceOffering(@Nullable ServiceOffering serviceOffering) { this.serviceOffering = serviceOffering; return this; } /** * Builds a new {@link ImmutableRawCloudServiceInstance ImmutableRawCloudServiceInstance}. * @return An immutable instance of RawCloudServiceInstance * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableRawCloudServiceInstance build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableRawCloudServiceInstance(resource, servicePlan, serviceOffering); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_RESOURCE) != 0) attributes.add("resource"); return "Cannot build RawCloudServiceInstance, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy