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

com.arakelian.elastic.model.ImmutableJsonSelector Maven / Gradle / Ivy

package com.arakelian.elastic.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.MoreObjects;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import com.jayway.jsonpath.JsonPath;
import java.io.ObjectStreamException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
import org.immutables.value.Generated;

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

* Use the builder to create immutable instances: * {@code ImmutableJsonSelector.builder()}. */ @Generated(from = "JsonSelector", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableJsonSelector extends JsonSelector { private final String selector; private ImmutableJsonSelector(String selector) { this.selector = selector; } /** * @return The value of the {@code selector} attribute */ @JsonProperty("selector") @Override public String getSelector() { return selector; } /** * Copy the current immutable object by setting a value for the {@link JsonSelector#getSelector() selector} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for selector * @return A modified copy of the {@code this} object */ public final ImmutableJsonSelector withSelector(String value) { String newValue = Objects.requireNonNull(value, "selector"); if (this.selector.equals(newValue)) return this; return validate(new ImmutableJsonSelector(newValue)); } /** * This instance is equal to all instances of {@code ImmutableJsonSelector} 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 ImmutableJsonSelector && equalTo((ImmutableJsonSelector) another); } private boolean equalTo(ImmutableJsonSelector another) { return selector.equals(another.selector); } /** * Computes a hash code from attributes: {@code selector}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + selector.hashCode(); return h; } /** * Prints the immutable value {@code JsonSelector} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("JsonSelector") .omitNullValues() .add("selector", selector) .toString(); } @SuppressWarnings("Immutable") private transient volatile long lazyInitBitmap; private static final long ARGUMENTS_LAZY_INIT_BIT = 0x1L; @SuppressWarnings("Immutable") private transient Map> arguments; /** * {@inheritDoc} *

* Returns a lazily initialized value of the {@link JsonSelector#getArguments() arguments} attribute. * Initialized once and only once and stored for subsequent access with proper synchronization. * In case of any exception or error thrown by the lazy value initializer, * the result will not be memoised (i.e. remembered) and on next call computation * will be attempted again. * @return A lazily initialized value of the {@code arguments} attribute */ @Override public Map> getArguments() { if ((lazyInitBitmap & ARGUMENTS_LAZY_INIT_BIT) == 0) { synchronized (this) { if ((lazyInitBitmap & ARGUMENTS_LAZY_INIT_BIT) == 0) { this.arguments = Objects.requireNonNull(super.getArguments(), "arguments"); lazyInitBitmap |= ARGUMENTS_LAZY_INIT_BIT; } } } return arguments; } private static final long FUNCTION_NAME_LAZY_INIT_BIT = 0x2L; @SuppressWarnings("Immutable") private transient String functionName; /** * {@inheritDoc} *

* Returns a lazily initialized value of the {@link JsonSelector#getFunctionName() functionName} attribute. * Initialized once and only once and stored for subsequent access with proper synchronization. * In case of any exception or error thrown by the lazy value initializer, * the result will not be memoised (i.e. remembered) and on next call computation * will be attempted again. * @return A lazily initialized value of the {@code functionName} attribute */ @Override public String getFunctionName() { if ((lazyInitBitmap & FUNCTION_NAME_LAZY_INIT_BIT) == 0) { synchronized (this) { if ((lazyInitBitmap & FUNCTION_NAME_LAZY_INIT_BIT) == 0) { this.functionName = Objects.requireNonNull(super.getFunctionName(), "functionName"); lazyInitBitmap |= FUNCTION_NAME_LAZY_INIT_BIT; } } } return functionName; } private static final long JSON_PATH_LAZY_INIT_BIT = 0x4L; @SuppressWarnings("Immutable") private transient JsonPath jsonPath; /** * {@inheritDoc} *

* Returns a lazily initialized value of the {@link JsonSelector#getJsonPath() jsonPath} attribute. * Initialized once and only once and stored for subsequent access with proper synchronization. * In case of any exception or error thrown by the lazy value initializer, * the result will not be memoised (i.e. remembered) and on next call computation * will be attempted again. * @return A lazily initialized value of the {@code jsonPath} attribute */ @Override public JsonPath getJsonPath() { if ((lazyInitBitmap & JSON_PATH_LAZY_INIT_BIT) == 0) { synchronized (this) { if ((lazyInitBitmap & JSON_PATH_LAZY_INIT_BIT) == 0) { this.jsonPath = Objects.requireNonNull(super.getJsonPath(), "jsonPath"); lazyInitBitmap |= JSON_PATH_LAZY_INIT_BIT; } } } return jsonPath; } private static final long PATH_LAZY_INIT_BIT = 0x8L; @SuppressWarnings("Immutable") private transient List path; /** * {@inheritDoc} *

* Returns a lazily initialized value of the {@link JsonSelector#getPath() path} attribute. * Initialized once and only once and stored for subsequent access with proper synchronization. * In case of any exception or error thrown by the lazy value initializer, * the result will not be memoised (i.e. remembered) and on next call computation * will be attempted again. * @return A lazily initialized value of the {@code path} attribute */ @Override public List getPath() { if ((lazyInitBitmap & PATH_LAZY_INIT_BIT) == 0) { synchronized (this) { if ((lazyInitBitmap & PATH_LAZY_INIT_BIT) == 0) { this.path = Objects.requireNonNull(super.getPath(), "path"); lazyInitBitmap |= PATH_LAZY_INIT_BIT; } } } return path; } private static final long TYPE_LAZY_INIT_BIT = 0x10L; @SuppressWarnings("Immutable") private transient JsonSelector.Type type; /** * {@inheritDoc} *

* Returns a lazily initialized value of the {@link JsonSelector#getType() type} attribute. * Initialized once and only once and stored for subsequent access with proper synchronization. * In case of any exception or error thrown by the lazy value initializer, * the result will not be memoised (i.e. remembered) and on next call computation * will be attempted again. * @return A lazily initialized value of the {@code type} attribute */ @Override public JsonSelector.Type getType() { if ((lazyInitBitmap & TYPE_LAZY_INIT_BIT) == 0) { synchronized (this) { if ((lazyInitBitmap & TYPE_LAZY_INIT_BIT) == 0) { this.type = Objects.requireNonNull(super.getType(), "type"); lazyInitBitmap |= TYPE_LAZY_INIT_BIT; } } } return type; } private static ImmutableJsonSelector validate(ImmutableJsonSelector instance) { instance = (ImmutableJsonSelector) instance.normalizeSelector(); return instance; } /** * Creates an immutable copy of a {@link JsonSelector} 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 JsonSelector instance */ public static ImmutableJsonSelector copyOf(JsonSelector instance) { if (instance instanceof ImmutableJsonSelector) { return (ImmutableJsonSelector) instance; } return ImmutableJsonSelector.builder() .from(instance) .build(); } private Object readResolve() throws ObjectStreamException { return validate(this); } /** * Creates a builder for {@link ImmutableJsonSelector ImmutableJsonSelector}. *

   * ImmutableJsonSelector.builder()
   *    .selector(String) // required {@link JsonSelector#getSelector() selector}
   *    .build();
   * 
* @return A new ImmutableJsonSelector builder */ public static ImmutableJsonSelector.Builder builder() { return new ImmutableJsonSelector.Builder(); } /** * Builds instances of type {@link ImmutableJsonSelector ImmutableJsonSelector}. * 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 = "JsonSelector", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_SELECTOR = 0x1L; private long initBits = 0x1L; private @Nullable String selector; private Builder() { } /** * Fill a builder with attribute values from the provided {@code JsonSelector} 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 Builder from(JsonSelector instance) { Objects.requireNonNull(instance, "instance"); selector(instance.getSelector()); return this; } /** * Initializes the value for the {@link JsonSelector#getSelector() selector} attribute. * @param selector The value for selector * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("selector") public final Builder selector(String selector) { this.selector = Objects.requireNonNull(selector, "selector"); initBits &= ~INIT_BIT_SELECTOR; return this; } /** * Builds a new {@link ImmutableJsonSelector ImmutableJsonSelector}. * @return An immutable instance of JsonSelector * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableJsonSelector build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return ImmutableJsonSelector.validate(new ImmutableJsonSelector(selector)); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_SELECTOR) != 0) attributes.add("selector"); return "Cannot build JsonSelector, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy