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

com.neotys.neoload.model.v3.binding.io.ImmutableProjectDescriptor Maven / Gradle / Ivy

package com.neotys.neoload.model.v3.binding.io;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.List;
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;
import javax.validation.Valid;

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

* Use the builder to create immutable instances: * {@code new ProjectDescriptor.Builder()}. */ @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "ProjectDescriptor"}) @Immutable @CheckReturnValue public final class ImmutableProjectDescriptor implements ProjectDescriptor { private final ImmutableList includes; private final com.neotys.neoload.model.v3.project.@Valid Project project; private ImmutableProjectDescriptor(ImmutableProjectDescriptor.Builder builder) { this.includes = builder.includes.build(); this.project = builder.project != null ? builder.project : Objects.requireNonNull(ProjectDescriptor.super.getProject(), "project"); } private ImmutableProjectDescriptor( ImmutableList includes, com.neotys.neoload.model.v3.project.@Valid Project project) { this.includes = includes; this.project = project; } /** * @return The value of the {@code includes} attribute */ @JsonProperty("includes") @Override public ImmutableList getIncludes() { return includes; } /** * @return The value of the {@code project} attribute */ @JsonProperty("project") @JsonUnwrapped @Override public com.neotys.neoload.model.v3.project.@Valid Project getProject() { return project; } /** * Copy the current immutable object with elements that replace the content of {@link ProjectDescriptor#getIncludes() includes}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableProjectDescriptor withIncludes(String... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableProjectDescriptor(newValue, this.project); } /** * Copy the current immutable object with elements that replace the content of {@link ProjectDescriptor#getIncludes() includes}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of includes elements to set * @return A modified copy of {@code this} object */ public final ImmutableProjectDescriptor withIncludes(Iterable elements) { if (this.includes == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableProjectDescriptor(newValue, this.project); } /** * Copy the current immutable object by setting a value for the {@link ProjectDescriptor#getProject() project} 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 project * @return A modified copy of the {@code this} object */ public final ImmutableProjectDescriptor withProject(com.neotys.neoload.model.v3.project.@Valid Project value) { if (this.project == value) return this; com.neotys.neoload.model.v3.project.@Valid Project newValue = Objects.requireNonNull(value, "project"); return new ImmutableProjectDescriptor(this.includes, newValue); } /** * This instance is equal to all instances of {@code ImmutableProjectDescriptor} 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 ImmutableProjectDescriptor && equalTo((ImmutableProjectDescriptor) another); } private boolean equalTo(ImmutableProjectDescriptor another) { return includes.equals(another.includes) && project.equals(another.project); } /** * Computes a hash code from attributes: {@code includes}, {@code project}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + includes.hashCode(); h += (h << 5) + project.hashCode(); return h; } /** * Prints the immutable value {@code ProjectDescriptor} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("ProjectDescriptor") .omitNullValues() .add("includes", includes) .add("project", project) .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 ProjectDescriptor { List includes = ImmutableList.of(); @Nullable com.neotys.neoload.model.v3.project.@Valid Project project; @JsonProperty("includes") public void setIncludes(List includes) { this.includes = includes; } @JsonProperty("project") @JsonUnwrapped public void setProject(com.neotys.neoload.model.v3.project.@Valid Project project) { this.project = project; } @Override public List getIncludes() { throw new UnsupportedOperationException(); } @Override public com.neotys.neoload.model.v3.project.@Valid Project getProject() { 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 ImmutableProjectDescriptor fromJson(Json json) { ProjectDescriptor.Builder builder = new ProjectDescriptor.Builder(); if (json.includes != null) { builder.addAllIncludes(json.includes); } if (json.project != null) { builder.project(json.project); } return (ImmutableProjectDescriptor) builder.build(); } /** * Creates an immutable copy of a {@link ProjectDescriptor} 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 ProjectDescriptor instance */ public static ImmutableProjectDescriptor copyOf(ProjectDescriptor instance) { if (instance instanceof ImmutableProjectDescriptor) { return (ImmutableProjectDescriptor) instance; } return new ProjectDescriptor.Builder() .from(instance) .build(); } /** * Builds instances of type {@link ImmutableProjectDescriptor ImmutableProjectDescriptor}. * 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 ImmutableList.Builder includes = ImmutableList.builder(); private @Nullable com.neotys.neoload.model.v3.project.@Valid Project project; /** * Creates a builder for {@link ImmutableProjectDescriptor ImmutableProjectDescriptor} instances. */ public Builder() { if (!(this instanceof ProjectDescriptor.Builder)) { throw new UnsupportedOperationException("Use: new ProjectDescriptor.Builder()"); } } /** * Fill a builder with attribute values from the provided {@code ProjectDescriptor} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * Collection elements and entries will be added, not replaced. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final ProjectDescriptor.Builder from(ProjectDescriptor instance) { Objects.requireNonNull(instance, "instance"); addAllIncludes(instance.getIncludes()); project(instance.getProject()); return (ProjectDescriptor.Builder) this; } /** * Adds one element to {@link ProjectDescriptor#getIncludes() includes} list. * @param element A includes element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final ProjectDescriptor.Builder addIncludes(String element) { this.includes.add(element); return (ProjectDescriptor.Builder) this; } /** * Adds elements to {@link ProjectDescriptor#getIncludes() includes} list. * @param elements An array of includes elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final ProjectDescriptor.Builder addIncludes(String... elements) { this.includes.add(elements); return (ProjectDescriptor.Builder) this; } /** * Sets or replaces all elements for {@link ProjectDescriptor#getIncludes() includes} list. * @param elements An iterable of includes elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("includes") public final ProjectDescriptor.Builder includes(Iterable elements) { this.includes = ImmutableList.builder(); return addAllIncludes(elements); } /** * Adds elements to {@link ProjectDescriptor#getIncludes() includes} list. * @param elements An iterable of includes elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final ProjectDescriptor.Builder addAllIncludes(Iterable elements) { this.includes.addAll(elements); return (ProjectDescriptor.Builder) this; } /** * Initializes the value for the {@link ProjectDescriptor#getProject() project} attribute. *

If not set, this attribute will have a default value as returned by the initializer of {@link ProjectDescriptor#getProject() project}. * @param project The value for project * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("project") @JsonUnwrapped public final ProjectDescriptor.Builder project(com.neotys.neoload.model.v3.project.@Valid Project project) { this.project = Objects.requireNonNull(project, "project"); return (ProjectDescriptor.Builder) this; } /** * Builds a new {@link ImmutableProjectDescriptor ImmutableProjectDescriptor}. * @return An immutable instance of ProjectDescriptor * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableProjectDescriptor build() { return new ImmutableProjectDescriptor(this); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy