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

org.immutables.fixture.jackson.ImmutableOptionIncludeNonEmptyWithConstructor Maven / Gradle / Ivy

package org.immutables.fixture.jackson;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.google.common.base.MoreObjects;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;

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

* Use the static factory method to create immutable instances: * {@code ImmutableOptionIncludeNonEmptyWithConstructor.of()}. */ @SuppressWarnings("all") @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "OptionIncludeNonEmptyWithConstructor"}) @Immutable final class ImmutableOptionIncludeNonEmptyWithConstructor extends OptionIncludeNonEmptyWithConstructor { private final Optional relationships; private ImmutableOptionIncludeNonEmptyWithConstructor(Optional relationships) { this.relationships = Preconditions.checkNotNull(relationships, "relationships"); } private ImmutableOptionIncludeNonEmptyWithConstructor( ImmutableOptionIncludeNonEmptyWithConstructor original, Optional relationships) { this.relationships = relationships; } /** * @return The value of the {@code relationships} attribute */ @JsonProperty @JsonInclude(value = JsonInclude.Include.NON_EMPTY) @Override public Optional getRelationships() { return relationships; } /** * Copy the current immutable object by setting a present value for the optional {@link OptionIncludeNonEmptyWithConstructor#getRelationships() relationships} attribute. * @param value The value for relationships * @return A modified copy of {@code this} object */ public final ImmutableOptionIncludeNonEmptyWithConstructor withRelationships(String value) { Optional newValue = Optional.of(value); if (this.relationships.equals(newValue)) return this; return new ImmutableOptionIncludeNonEmptyWithConstructor(this, newValue); } /** * Copy the current immutable object by setting an optional value for the {@link OptionIncludeNonEmptyWithConstructor#getRelationships() relationships} attribute. * An equality check is used to prevent copying of the same value by returning {@code this}. * @param optional A value for relationships * @return A modified copy of {@code this} object */ public final ImmutableOptionIncludeNonEmptyWithConstructor withRelationships(Optional optional) { Optional value = Preconditions.checkNotNull(optional, "relationships"); if (this.relationships.equals(value)) return this; return new ImmutableOptionIncludeNonEmptyWithConstructor(this, value); } /** * This instance is equal to all instances of {@code ImmutableOptionIncludeNonEmptyWithConstructor} 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 ImmutableOptionIncludeNonEmptyWithConstructor && equalTo((ImmutableOptionIncludeNonEmptyWithConstructor) another); } private boolean equalTo(ImmutableOptionIncludeNonEmptyWithConstructor another) { return relationships.equals(another.relationships); } /** * Computes a hash code from attributes: {@code relationships}. * @return hashCode value */ @Override public int hashCode() { int h = 31; h = h * 17 + relationships.hashCode(); return h; } /** * Prints the immutable value {@code OptionIncludeNonEmptyWithConstructor} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("OptionIncludeNonEmptyWithConstructor") .omitNullValues() .add("relationships", relationships.orNull()) .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 static final class Json extends OptionIncludeNonEmptyWithConstructor { Optional relationships = Optional.absent(); @JsonProperty @JsonInclude(value = JsonInclude.Include.NON_EMPTY) public void setRelationships(Optional relationships) { this.relationships = relationships; } @Override public Optional getRelationships() { 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 static ImmutableOptionIncludeNonEmptyWithConstructor fromJson(Json json) { ImmutableOptionIncludeNonEmptyWithConstructor instance = ImmutableOptionIncludeNonEmptyWithConstructor.of(json.relationships); return instance; } /** * Construct a new immutable {@code OptionIncludeNonEmptyWithConstructor} instance. * @param relationships The value for the {@code relationships} attribute * @return An immutable OptionIncludeNonEmptyWithConstructor instance */ public static ImmutableOptionIncludeNonEmptyWithConstructor of(Optional relationships) { return new ImmutableOptionIncludeNonEmptyWithConstructor(relationships); } /** * Creates an immutable copy of a {@link OptionIncludeNonEmptyWithConstructor} 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 OptionIncludeNonEmptyWithConstructor instance */ public static ImmutableOptionIncludeNonEmptyWithConstructor copyOf(OptionIncludeNonEmptyWithConstructor instance) { if (instance instanceof ImmutableOptionIncludeNonEmptyWithConstructor) { return (ImmutableOptionIncludeNonEmptyWithConstructor) instance; } return ImmutableOptionIncludeNonEmptyWithConstructor.of(instance.getRelationships()); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy