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

org.cloudfoundry.client.lib.adapters.ImmutableRawApplicationLog Maven / Gradle / Ivy

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

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.cloudfoundry.doppler.Envelope;
import org.immutables.value.Generated;

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

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

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





© 2015 - 2024 Weber Informatics LLC | Privacy Policy