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

org.cloudfoundry.multiapps.controller.process.dynatrace.ImmutableDynatraceProcessDuration Maven / Gradle / Ivy

There is a newer version: 1.183.0
Show newest version
package org.cloudfoundry.multiapps.controller.process.dynatrace;

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 com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.cloudfoundry.multiapps.common.Nullable;
import org.cloudfoundry.multiapps.controller.api.model.Operation;
import org.cloudfoundry.multiapps.controller.api.model.ProcessType;
import org.cloudfoundry.multiapps.controller.api.model.ProcessTypeDeserializer;
import org.cloudfoundry.multiapps.controller.api.model.ProcessTypeSerializer;

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

* Use the builder to create immutable instances: * {@code ImmutableDynatraceProcessDuration.builder()}. */ @SuppressWarnings({"all"}) public final class ImmutableDynatraceProcessDuration extends DynatraceProcessDuration { private final @Nullable String processId; private final @Nullable ProcessType processType; private final @Nullable String spaceId; private final @Nullable String mtaId; private final long processDuration; private final Operation.State operationState; private ImmutableDynatraceProcessDuration( @Nullable String processId, @Nullable ProcessType processType, @Nullable String spaceId, @Nullable String mtaId, long processDuration, Operation.State operationState) { this.processId = processId; this.processType = processType; this.spaceId = spaceId; this.mtaId = mtaId; this.processDuration = processDuration; this.operationState = operationState; } /** * @return The value of the {@code processId} attribute */ @JsonProperty("processId") @Override public @Nullable String getProcessId() { return processId; } /** * @return The value of the {@code processType} attribute */ @JsonProperty("processType") @JsonSerialize(using = ProcessTypeSerializer.class) @JsonDeserialize(using = ProcessTypeDeserializer.class) @Override public @Nullable ProcessType getProcessType() { return processType; } /** * @return The value of the {@code spaceId} attribute */ @JsonProperty("spaceId") @Override public @Nullable String getSpaceId() { return spaceId; } /** * @return The value of the {@code mtaId} attribute */ @JsonProperty("mtaId") @Override public @Nullable String getMtaId() { return mtaId; } /** * @return The value of the {@code processDuration} attribute */ @JsonProperty("processDuration") @Override public long getProcessDuration() { return processDuration; } /** * @return The value of the {@code operationState} attribute */ @JsonProperty("operationState") @Override public Operation.State getOperationState() { return operationState; } /** * Copy the current immutable object by setting a value for the {@link DynatraceProcessDuration#getProcessId() processId} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for processId (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableDynatraceProcessDuration withProcessId(@Nullable String value) { if (Objects.equals(this.processId, value)) return this; return new ImmutableDynatraceProcessDuration(value, this.processType, this.spaceId, this.mtaId, this.processDuration, this.operationState); } /** * Copy the current immutable object by setting a value for the {@link DynatraceProcessDuration#getProcessType() processType} 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 processType (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableDynatraceProcessDuration withProcessType(@Nullable ProcessType value) { if (this.processType == value) return this; return new ImmutableDynatraceProcessDuration(this.processId, value, this.spaceId, this.mtaId, this.processDuration, this.operationState); } /** * Copy the current immutable object by setting a value for the {@link DynatraceProcessDuration#getSpaceId() spaceId} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for spaceId (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableDynatraceProcessDuration withSpaceId(@Nullable String value) { if (Objects.equals(this.spaceId, value)) return this; return new ImmutableDynatraceProcessDuration(this.processId, this.processType, value, this.mtaId, this.processDuration, this.operationState); } /** * Copy the current immutable object by setting a value for the {@link DynatraceProcessDuration#getMtaId() mtaId} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for mtaId (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableDynatraceProcessDuration withMtaId(@Nullable String value) { if (Objects.equals(this.mtaId, value)) return this; return new ImmutableDynatraceProcessDuration( this.processId, this.processType, this.spaceId, value, this.processDuration, this.operationState); } /** * Copy the current immutable object by setting a value for the {@link DynatraceProcessDuration#getProcessDuration() processDuration} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for processDuration * @return A modified copy of the {@code this} object */ public final ImmutableDynatraceProcessDuration withProcessDuration(long value) { if (this.processDuration == value) return this; return new ImmutableDynatraceProcessDuration(this.processId, this.processType, this.spaceId, this.mtaId, value, this.operationState); } /** * Copy the current immutable object by setting a value for the {@link DynatraceProcessDuration#getOperationState() operationState} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for operationState * @return A modified copy of the {@code this} object */ public final ImmutableDynatraceProcessDuration withOperationState(Operation.State value) { Operation.State newValue = Objects.requireNonNull(value, "operationState"); if (this.operationState == newValue) return this; return new ImmutableDynatraceProcessDuration(this.processId, this.processType, this.spaceId, this.mtaId, this.processDuration, newValue); } /** * This instance is equal to all instances of {@code ImmutableDynatraceProcessDuration} 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 ImmutableDynatraceProcessDuration && equalTo(0, (ImmutableDynatraceProcessDuration) another); } private boolean equalTo(int synthetic, ImmutableDynatraceProcessDuration another) { return Objects.equals(processId, another.processId) && Objects.equals(processType, another.processType) && Objects.equals(spaceId, another.spaceId) && Objects.equals(mtaId, another.mtaId) && processDuration == another.processDuration && operationState.equals(another.operationState); } /** * Computes a hash code from attributes: {@code processId}, {@code processType}, {@code spaceId}, {@code mtaId}, {@code processDuration}, {@code operationState}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + Objects.hashCode(processId); h += (h << 5) + Objects.hashCode(processType); h += (h << 5) + Objects.hashCode(spaceId); h += (h << 5) + Objects.hashCode(mtaId); h += (h << 5) + Long.hashCode(processDuration); h += (h << 5) + operationState.hashCode(); return h; } /** * Prints the immutable value {@code DynatraceProcessDuration} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "DynatraceProcessDuration{" + "processId=" + processId + ", processType=" + processType + ", spaceId=" + spaceId + ", mtaId=" + mtaId + ", processDuration=" + processDuration + ", operationState=" + operationState + "}"; } /** * 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 */ @Deprecated @JsonDeserialize @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json extends DynatraceProcessDuration { String processId; ProcessType processType; String spaceId; String mtaId; long processDuration; boolean processDurationIsSet; Operation.State operationState; @JsonProperty("processId") public void setProcessId(@Nullable String processId) { this.processId = processId; } @JsonProperty("processType") @JsonSerialize(using = ProcessTypeSerializer.class) @JsonDeserialize(using = ProcessTypeDeserializer.class) public void setProcessType(@Nullable ProcessType processType) { this.processType = processType; } @JsonProperty("spaceId") public void setSpaceId(@Nullable String spaceId) { this.spaceId = spaceId; } @JsonProperty("mtaId") public void setMtaId(@Nullable String mtaId) { this.mtaId = mtaId; } @JsonProperty("processDuration") public void setProcessDuration(long processDuration) { this.processDuration = processDuration; this.processDurationIsSet = true; } @JsonProperty("operationState") public void setOperationState(Operation.State operationState) { this.operationState = operationState; } @Override public String getProcessId() { throw new UnsupportedOperationException(); } @Override public ProcessType getProcessType() { throw new UnsupportedOperationException(); } @Override public String getSpaceId() { throw new UnsupportedOperationException(); } @Override public String getMtaId() { throw new UnsupportedOperationException(); } @Override public long getProcessDuration() { throw new UnsupportedOperationException(); } @Override public Operation.State getOperationState() { 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 ImmutableDynatraceProcessDuration fromJson(Json json) { ImmutableDynatraceProcessDuration.Builder builder = ImmutableDynatraceProcessDuration.builder(); if (json.processId != null) { builder.processId(json.processId); } if (json.processType != null) { builder.processType(json.processType); } if (json.spaceId != null) { builder.spaceId(json.spaceId); } if (json.mtaId != null) { builder.mtaId(json.mtaId); } if (json.processDurationIsSet) { builder.processDuration(json.processDuration); } if (json.operationState != null) { builder.operationState(json.operationState); } return builder.build(); } /** * Creates an immutable copy of a {@link DynatraceProcessDuration} 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 DynatraceProcessDuration instance */ public static ImmutableDynatraceProcessDuration copyOf(DynatraceProcessDuration instance) { if (instance instanceof ImmutableDynatraceProcessDuration) { return (ImmutableDynatraceProcessDuration) instance; } return ImmutableDynatraceProcessDuration.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableDynatraceProcessDuration ImmutableDynatraceProcessDuration}. *

   * ImmutableDynatraceProcessDuration.builder()
   *    .processId(String | null) // nullable {@link DynatraceProcessDuration#getProcessId() processId}
   *    .processType(org.cloudfoundry.multiapps.controller.api.model.ProcessType | null) // nullable {@link DynatraceProcessDuration#getProcessType() processType}
   *    .spaceId(String | null) // nullable {@link DynatraceProcessDuration#getSpaceId() spaceId}
   *    .mtaId(String | null) // nullable {@link DynatraceProcessDuration#getMtaId() mtaId}
   *    .processDuration(long) // required {@link DynatraceProcessDuration#getProcessDuration() processDuration}
   *    .operationState(org.cloudfoundry.multiapps.controller.api.model.Operation.State) // required {@link DynatraceProcessDuration#getOperationState() operationState}
   *    .build();
   * 
* @return A new ImmutableDynatraceProcessDuration builder */ public static ImmutableDynatraceProcessDuration.Builder builder() { return new ImmutableDynatraceProcessDuration.Builder(); } /** * Builds instances of type {@link ImmutableDynatraceProcessDuration ImmutableDynatraceProcessDuration}. * 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. */ public static final class Builder { private static final long INIT_BIT_PROCESS_DURATION = 0x1L; private static final long INIT_BIT_OPERATION_STATE = 0x2L; private long initBits = 0x3L; private String processId; private ProcessType processType; private String spaceId; private String mtaId; private long processDuration; private Operation.State operationState; private Builder() { } /** * Fill a builder with attribute values from the provided {@code org.cloudfoundry.multiapps.controller.process.dynatrace.DynatraceProcessDuration} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(DynatraceProcessDuration instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code org.cloudfoundry.multiapps.controller.process.dynatrace.DyntraceProcessEntity} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(DyntraceProcessEntity instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } private void from(short _unused, Object object) { if (object instanceof DynatraceProcessDuration) { DynatraceProcessDuration instance = (DynatraceProcessDuration) object; this.processDuration(instance.getProcessDuration()); this.operationState(instance.getOperationState()); } if (object instanceof DyntraceProcessEntity) { DyntraceProcessEntity instance = (DyntraceProcessEntity) object; @Nullable String spaceIdValue = instance.getSpaceId(); if (spaceIdValue != null) { spaceId(spaceIdValue); } @Nullable String mtaIdValue = instance.getMtaId(); if (mtaIdValue != null) { mtaId(mtaIdValue); } @Nullable ProcessType processTypeValue = instance.getProcessType(); if (processTypeValue != null) { processType(processTypeValue); } @Nullable String processIdValue = instance.getProcessId(); if (processIdValue != null) { processId(processIdValue); } } } /** * Initializes the value for the {@link DynatraceProcessDuration#getProcessId() processId} attribute. * @param processId The value for processId (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("processId") public final Builder processId(@Nullable String processId) { this.processId = processId; return this; } /** * Initializes the value for the {@link DynatraceProcessDuration#getProcessType() processType} attribute. * @param processType The value for processType (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("processType") @JsonSerialize(using = ProcessTypeSerializer.class) @JsonDeserialize(using = ProcessTypeDeserializer.class) public final Builder processType(@Nullable ProcessType processType) { this.processType = processType; return this; } /** * Initializes the value for the {@link DynatraceProcessDuration#getSpaceId() spaceId} attribute. * @param spaceId The value for spaceId (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("spaceId") public final Builder spaceId(@Nullable String spaceId) { this.spaceId = spaceId; return this; } /** * Initializes the value for the {@link DynatraceProcessDuration#getMtaId() mtaId} attribute. * @param mtaId The value for mtaId (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("mtaId") public final Builder mtaId(@Nullable String mtaId) { this.mtaId = mtaId; return this; } /** * Initializes the value for the {@link DynatraceProcessDuration#getProcessDuration() processDuration} attribute. * @param processDuration The value for processDuration * @return {@code this} builder for use in a chained invocation */ @JsonProperty("processDuration") public final Builder processDuration(long processDuration) { this.processDuration = processDuration; initBits &= ~INIT_BIT_PROCESS_DURATION; return this; } /** * Initializes the value for the {@link DynatraceProcessDuration#getOperationState() operationState} attribute. * @param operationState The value for operationState * @return {@code this} builder for use in a chained invocation */ @JsonProperty("operationState") public final Builder operationState(Operation.State operationState) { this.operationState = Objects.requireNonNull(operationState, "operationState"); initBits &= ~INIT_BIT_OPERATION_STATE; return this; } /** * Builds a new {@link ImmutableDynatraceProcessDuration ImmutableDynatraceProcessDuration}. * @return An immutable instance of DynatraceProcessDuration * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableDynatraceProcessDuration build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableDynatraceProcessDuration(processId, processType, spaceId, mtaId, processDuration, operationState); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_PROCESS_DURATION) != 0) attributes.add("processDuration"); if ((initBits & INIT_BIT_OPERATION_STATE) != 0) attributes.add("operationState"); return "Cannot build DynatraceProcessDuration, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy