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

com.neotys.neoload.model.scenario.ImmutableStopAfter Maven / Gradle / Ivy

package com.neotys.neoload.model.scenario;

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.google.common.base.MoreObjects;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.Objects;
import javax.annotation.CheckReturnValue;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;

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

* Use the builder to create immutable instances: * {@code new StopAfter.Builder()}. */ @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "StopAfter"}) @Deprecated @Immutable @CheckReturnValue public final class ImmutableStopAfter implements StopAfter { private final Object value; private final StopAfter.Type type; private ImmutableStopAfter(Object value, StopAfter.Type type) { this.value = value; this.type = type; } /** * @return The value of the {@code value} attribute */ @JsonProperty("value") @Override public Object getValue() { return value; } /** * @return The value of the {@code type} attribute */ @JsonProperty("type") @Override public StopAfter.Type getType() { return type; } /** * Copy the current immutable object by setting a value for the {@link StopAfter#getValue() value} 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 value (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableStopAfter withValue(Object value) { if (this.value == value) return this; return new ImmutableStopAfter(value, this.type); } /** * Copy the current immutable object by setting a value for the {@link StopAfter#getType() type} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for type (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableStopAfter withType(StopAfter.Type value) { if (this.type == value) return this; return new ImmutableStopAfter(this.value, value); } /** * This instance is equal to all instances of {@code ImmutableStopAfter} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(@Nullable Object another) { if (this == another) return true; return another instanceof ImmutableStopAfter && equalTo((ImmutableStopAfter) another); } private boolean equalTo(ImmutableStopAfter another) { return Objects.equals(value, another.value) && Objects.equals(type, another.type); } /** * Computes a hash code from attributes: {@code value}, {@code type}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + Objects.hashCode(value); h += (h << 5) + Objects.hashCode(type); return h; } /** * Prints the immutable value {@code StopAfter} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("StopAfter") .omitNullValues() .add("value", value) .add("type", type) .toString(); } /** * 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 implements StopAfter { @Nullable Object value; @Nullable StopAfter.Type type; @JsonProperty("value") public void setValue(Object value) { this.value = value; } @JsonProperty("type") public void setType(StopAfter.Type type) { this.type = type; } @Override public Object getValue() { throw new UnsupportedOperationException(); } @Override public StopAfter.Type getType() { 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 ImmutableStopAfter fromJson(Json json) { StopAfter.Builder builder = new StopAfter.Builder(); if (json.value != null) { builder.value(json.value); } if (json.type != null) { builder.type(json.type); } return (ImmutableStopAfter) builder.build(); } /** * Creates an immutable copy of a {@link StopAfter} 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 StopAfter instance */ public static ImmutableStopAfter copyOf(StopAfter instance) { if (instance instanceof ImmutableStopAfter) { return (ImmutableStopAfter) instance; } return new StopAfter.Builder() .from(instance) .build(); } /** * Builds instances of type {@link ImmutableStopAfter ImmutableStopAfter}. * 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. */ @NotThreadSafe public static class Builder { private @Nullable Object value; private @Nullable StopAfter.Type type; /** * Creates a builder for {@link ImmutableStopAfter ImmutableStopAfter} instances. */ public Builder() { if (!(this instanceof StopAfter.Builder)) { throw new UnsupportedOperationException("Use: new StopAfter.Builder()"); } } /** * Fill a builder with attribute values from the provided {@code StopAfter} 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 */ @CanIgnoreReturnValue public final StopAfter.Builder from(StopAfter instance) { Objects.requireNonNull(instance, "instance"); Object valueValue = instance.getValue(); if (valueValue != null) { value(valueValue); } StopAfter.Type typeValue = instance.getType(); if (typeValue != null) { type(typeValue); } return (StopAfter.Builder) this; } /** * Initializes the value for the {@link StopAfter#getValue() value} attribute. * @param value The value for value (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("value") public final StopAfter.Builder value(Object value) { this.value = value; return (StopAfter.Builder) this; } /** * Initializes the value for the {@link StopAfter#getType() type} attribute. * @param type The value for type (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("type") public final StopAfter.Builder type(StopAfter.Type type) { this.type = type; return (StopAfter.Builder) this; } /** * Builds a new {@link ImmutableStopAfter ImmutableStopAfter}. * @return An immutable instance of StopAfter * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableStopAfter build() { return new ImmutableStopAfter(value, type); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy