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

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

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

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import org.immutables.value.Generated;

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

* Use the builder to create immutable instances: * {@code ImmutableApplicationLog.builder()}. */ @Generated(from = "ApplicationLog", generator = "Immutables") @SuppressWarnings({"all"}) @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableApplicationLog extends ApplicationLog { private final String applicationGuid; private final String message; private final Date timestamp; private final ApplicationLog.MessageType messageType; private final String sourceId; private final String sourceName; private ImmutableApplicationLog( String applicationGuid, String message, Date timestamp, ApplicationLog.MessageType messageType, String sourceId, String sourceName) { this.applicationGuid = applicationGuid; this.message = message; this.timestamp = timestamp; this.messageType = messageType; this.sourceId = sourceId; this.sourceName = sourceName; } /** * @return The value of the {@code applicationGuid} attribute */ @Override public String getApplicationGuid() { return applicationGuid; } /** * @return The value of the {@code message} attribute */ @Override public String getMessage() { return message; } /** * @return The value of the {@code timestamp} attribute */ @Override public Date getTimestamp() { return timestamp; } /** * @return The value of the {@code messageType} attribute */ @Override public ApplicationLog.MessageType getMessageType() { return messageType; } /** * @return The value of the {@code sourceId} attribute */ @Override public String getSourceId() { return sourceId; } /** * @return The value of the {@code sourceName} attribute */ @Override public String getSourceName() { return sourceName; } /** * Copy the current immutable object by setting a value for the {@link ApplicationLog#getApplicationGuid() applicationGuid} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for applicationGuid * @return A modified copy of the {@code this} object */ public final ImmutableApplicationLog withApplicationGuid(String value) { String newValue = Objects.requireNonNull(value, "applicationGuid"); if (this.applicationGuid.equals(newValue)) return this; return new ImmutableApplicationLog(newValue, this.message, this.timestamp, this.messageType, this.sourceId, this.sourceName); } /** * Copy the current immutable object by setting a value for the {@link ApplicationLog#getMessage() message} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for message * @return A modified copy of the {@code this} object */ public final ImmutableApplicationLog withMessage(String value) { String newValue = Objects.requireNonNull(value, "message"); if (this.message.equals(newValue)) return this; return new ImmutableApplicationLog( this.applicationGuid, newValue, this.timestamp, this.messageType, this.sourceId, this.sourceName); } /** * Copy the current immutable object by setting a value for the {@link ApplicationLog#getTimestamp() timestamp} 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 timestamp * @return A modified copy of the {@code this} object */ public final ImmutableApplicationLog withTimestamp(Date value) { if (this.timestamp == value) return this; Date newValue = Objects.requireNonNull(value, "timestamp"); return new ImmutableApplicationLog(this.applicationGuid, this.message, newValue, this.messageType, this.sourceId, this.sourceName); } /** * Copy the current immutable object by setting a value for the {@link ApplicationLog#getMessageType() messageType} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for messageType * @return A modified copy of the {@code this} object */ public final ImmutableApplicationLog withMessageType(ApplicationLog.MessageType value) { if (this.messageType == value) return this; ApplicationLog.MessageType newValue = Objects.requireNonNull(value, "messageType"); if (this.messageType.equals(newValue)) return this; return new ImmutableApplicationLog(this.applicationGuid, this.message, this.timestamp, newValue, this.sourceId, this.sourceName); } /** * Copy the current immutable object by setting a value for the {@link ApplicationLog#getSourceId() sourceId} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for sourceId * @return A modified copy of the {@code this} object */ public final ImmutableApplicationLog withSourceId(String value) { String newValue = Objects.requireNonNull(value, "sourceId"); if (this.sourceId.equals(newValue)) return this; return new ImmutableApplicationLog(this.applicationGuid, this.message, this.timestamp, this.messageType, newValue, this.sourceName); } /** * Copy the current immutable object by setting a value for the {@link ApplicationLog#getSourceName() sourceName} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for sourceName * @return A modified copy of the {@code this} object */ public final ImmutableApplicationLog withSourceName(String value) { String newValue = Objects.requireNonNull(value, "sourceName"); if (this.sourceName.equals(newValue)) return this; return new ImmutableApplicationLog(this.applicationGuid, this.message, this.timestamp, this.messageType, this.sourceId, newValue); } /** * This instance is equal to all instances of {@code ImmutableApplicationLog} 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 ImmutableApplicationLog && equalTo((ImmutableApplicationLog) another); } private boolean equalTo(ImmutableApplicationLog another) { return applicationGuid.equals(another.applicationGuid) && message.equals(another.message) && timestamp.equals(another.timestamp) && messageType.equals(another.messageType) && sourceId.equals(another.sourceId) && sourceName.equals(another.sourceName); } /** * Computes a hash code from attributes: {@code applicationGuid}, {@code message}, {@code timestamp}, {@code messageType}, {@code sourceId}, {@code sourceName}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + applicationGuid.hashCode(); h += (h << 5) + message.hashCode(); h += (h << 5) + timestamp.hashCode(); h += (h << 5) + messageType.hashCode(); h += (h << 5) + sourceId.hashCode(); h += (h << 5) + sourceName.hashCode(); return h; } /** * Creates an immutable copy of a {@link ApplicationLog} 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 ApplicationLog instance */ public static ImmutableApplicationLog copyOf(ApplicationLog instance) { if (instance instanceof ImmutableApplicationLog) { return (ImmutableApplicationLog) instance; } return ImmutableApplicationLog.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableApplicationLog ImmutableApplicationLog}. *

   * ImmutableApplicationLog.builder()
   *    .applicationGuid(String) // required {@link ApplicationLog#getApplicationGuid() applicationGuid}
   *    .message(String) // required {@link ApplicationLog#getMessage() message}
   *    .timestamp(Date) // required {@link ApplicationLog#getTimestamp() timestamp}
   *    .messageType(org.cloudfoundry.client.lib.domain.ApplicationLog.MessageType) // required {@link ApplicationLog#getMessageType() messageType}
   *    .sourceId(String) // required {@link ApplicationLog#getSourceId() sourceId}
   *    .sourceName(String) // required {@link ApplicationLog#getSourceName() sourceName}
   *    .build();
   * 
* @return A new ImmutableApplicationLog builder */ public static ImmutableApplicationLog.Builder builder() { return new ImmutableApplicationLog.Builder(); } /** * Builds instances of type {@link ImmutableApplicationLog ImmutableApplicationLog}. * 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 = "ApplicationLog", generator = "Immutables") public static final class Builder { private static final long INIT_BIT_APPLICATION_GUID = 0x1L; private static final long INIT_BIT_MESSAGE = 0x2L; private static final long INIT_BIT_TIMESTAMP = 0x4L; private static final long INIT_BIT_MESSAGE_TYPE = 0x8L; private static final long INIT_BIT_SOURCE_ID = 0x10L; private static final long INIT_BIT_SOURCE_NAME = 0x20L; private long initBits = 0x3fL; private String applicationGuid; private String message; private Date timestamp; private ApplicationLog.MessageType messageType; private String sourceId; private String sourceName; private Builder() { } /** * Fill a builder with attribute values from the provided {@code ApplicationLog} 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(ApplicationLog instance) { Objects.requireNonNull(instance, "instance"); applicationGuid(instance.getApplicationGuid()); message(instance.getMessage()); timestamp(instance.getTimestamp()); messageType(instance.getMessageType()); sourceId(instance.getSourceId()); sourceName(instance.getSourceName()); return this; } /** * Initializes the value for the {@link ApplicationLog#getApplicationGuid() applicationGuid} attribute. * @param applicationGuid The value for applicationGuid * @return {@code this} builder for use in a chained invocation */ public final Builder applicationGuid(String applicationGuid) { this.applicationGuid = Objects.requireNonNull(applicationGuid, "applicationGuid"); initBits &= ~INIT_BIT_APPLICATION_GUID; return this; } /** * Initializes the value for the {@link ApplicationLog#getMessage() message} attribute. * @param message The value for message * @return {@code this} builder for use in a chained invocation */ public final Builder message(String message) { this.message = Objects.requireNonNull(message, "message"); initBits &= ~INIT_BIT_MESSAGE; return this; } /** * Initializes the value for the {@link ApplicationLog#getTimestamp() timestamp} attribute. * @param timestamp The value for timestamp * @return {@code this} builder for use in a chained invocation */ public final Builder timestamp(Date timestamp) { this.timestamp = Objects.requireNonNull(timestamp, "timestamp"); initBits &= ~INIT_BIT_TIMESTAMP; return this; } /** * Initializes the value for the {@link ApplicationLog#getMessageType() messageType} attribute. * @param messageType The value for messageType * @return {@code this} builder for use in a chained invocation */ public final Builder messageType(ApplicationLog.MessageType messageType) { this.messageType = Objects.requireNonNull(messageType, "messageType"); initBits &= ~INIT_BIT_MESSAGE_TYPE; return this; } /** * Initializes the value for the {@link ApplicationLog#getSourceId() sourceId} attribute. * @param sourceId The value for sourceId * @return {@code this} builder for use in a chained invocation */ public final Builder sourceId(String sourceId) { this.sourceId = Objects.requireNonNull(sourceId, "sourceId"); initBits &= ~INIT_BIT_SOURCE_ID; return this; } /** * Initializes the value for the {@link ApplicationLog#getSourceName() sourceName} attribute. * @param sourceName The value for sourceName * @return {@code this} builder for use in a chained invocation */ public final Builder sourceName(String sourceName) { this.sourceName = Objects.requireNonNull(sourceName, "sourceName"); initBits &= ~INIT_BIT_SOURCE_NAME; return this; } /** * Builds a new {@link ImmutableApplicationLog ImmutableApplicationLog}. * @return An immutable instance of ApplicationLog * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableApplicationLog build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableApplicationLog(applicationGuid, message, timestamp, messageType, sourceId, sourceName); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_APPLICATION_GUID) != 0) attributes.add("applicationGuid"); if ((initBits & INIT_BIT_MESSAGE) != 0) attributes.add("message"); if ((initBits & INIT_BIT_TIMESTAMP) != 0) attributes.add("timestamp"); if ((initBits & INIT_BIT_MESSAGE_TYPE) != 0) attributes.add("messageType"); if ((initBits & INIT_BIT_SOURCE_ID) != 0) attributes.add("sourceId"); if ((initBits & INIT_BIT_SOURCE_NAME) != 0) attributes.add("sourceName"); return "Cannot build ApplicationLog, some of required attributes are not set " + attributes; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy