
wtf.metio.yosql.models.configuration.ImmutableResultRowConverter Maven / Gradle / Ivy
package wtf.metio.yosql.models.configuration;
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.squareup.javapoet.TypeName;
import java.util.Objects;
import java.util.Optional;
import org.immutables.value.Generated;
/**
* Immutable implementation of {@link ResultRowConverter}.
*
* Use the builder to create immutable instances:
* {@code ImmutableResultRowConverter.builder()}.
*/
@Generated(from = "ResultRowConverter", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
public final class ImmutableResultRowConverter
implements ResultRowConverter {
private final String alias;
private final String converterType;
private final String methodName;
private final String resultType;
private ImmutableResultRowConverter(
String alias,
String converterType,
String methodName,
String resultType) {
this.alias = alias;
this.converterType = converterType;
this.methodName = methodName;
this.resultType = resultType;
}
/**
* @return The (short) alias of this converter.
*/
@JsonProperty("alias")
@Override
public Optional alias() {
return Optional.ofNullable(alias);
}
/**
* @return The fully-qualified type name of this converter.
*/
@JsonProperty("converterType")
@Override
public Optional converterType() {
return Optional.ofNullable(converterType);
}
/**
* @return The name of the method to use while converting values.
*/
@JsonProperty("methodName")
@Override
public Optional methodName() {
return Optional.ofNullable(methodName);
}
/**
* @return The fully-qualified result type of this converter.
*/
@JsonProperty("resultType")
@Override
public Optional resultType() {
return Optional.ofNullable(resultType);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link ResultRowConverter#alias() alias} attribute.
* @param value The value for alias
* @return A modified copy of {@code this} object
*/
public final ImmutableResultRowConverter withAlias(String value) {
String newValue = Objects.requireNonNull(value, "alias");
if (Objects.equals(this.alias, newValue)) return this;
return new ImmutableResultRowConverter(newValue, this.converterType, this.methodName, this.resultType);
}
/**
* Copy the current immutable object by setting an optional value for the {@link ResultRowConverter#alias() alias} attribute.
* An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}.
* @param optional A value for alias
* @return A modified copy of {@code this} object
*/
public final ImmutableResultRowConverter withAlias(Optional optional) {
String value = optional.orElse(null);
if (Objects.equals(this.alias, value)) return this;
return new ImmutableResultRowConverter(value, this.converterType, this.methodName, this.resultType);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link ResultRowConverter#converterType() converterType} attribute.
* @param value The value for converterType
* @return A modified copy of {@code this} object
*/
public final ImmutableResultRowConverter withConverterType(String value) {
String newValue = Objects.requireNonNull(value, "converterType");
if (Objects.equals(this.converterType, newValue)) return this;
return new ImmutableResultRowConverter(this.alias, newValue, this.methodName, this.resultType);
}
/**
* Copy the current immutable object by setting an optional value for the {@link ResultRowConverter#converterType() converterType} attribute.
* An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}.
* @param optional A value for converterType
* @return A modified copy of {@code this} object
*/
public final ImmutableResultRowConverter withConverterType(Optional optional) {
String value = optional.orElse(null);
if (Objects.equals(this.converterType, value)) return this;
return new ImmutableResultRowConverter(this.alias, value, this.methodName, this.resultType);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link ResultRowConverter#methodName() methodName} attribute.
* @param value The value for methodName
* @return A modified copy of {@code this} object
*/
public final ImmutableResultRowConverter withMethodName(String value) {
String newValue = Objects.requireNonNull(value, "methodName");
if (Objects.equals(this.methodName, newValue)) return this;
return new ImmutableResultRowConverter(this.alias, this.converterType, newValue, this.resultType);
}
/**
* Copy the current immutable object by setting an optional value for the {@link ResultRowConverter#methodName() methodName} attribute.
* An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}.
* @param optional A value for methodName
* @return A modified copy of {@code this} object
*/
public final ImmutableResultRowConverter withMethodName(Optional optional) {
String value = optional.orElse(null);
if (Objects.equals(this.methodName, value)) return this;
return new ImmutableResultRowConverter(this.alias, this.converterType, value, this.resultType);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link ResultRowConverter#resultType() resultType} attribute.
* @param value The value for resultType
* @return A modified copy of {@code this} object
*/
public final ImmutableResultRowConverter withResultType(String value) {
String newValue = Objects.requireNonNull(value, "resultType");
if (Objects.equals(this.resultType, newValue)) return this;
return new ImmutableResultRowConverter(this.alias, this.converterType, this.methodName, newValue);
}
/**
* Copy the current immutable object by setting an optional value for the {@link ResultRowConverter#resultType() resultType} attribute.
* An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}.
* @param optional A value for resultType
* @return A modified copy of {@code this} object
*/
public final ImmutableResultRowConverter withResultType(Optional optional) {
String value = optional.orElse(null);
if (Objects.equals(this.resultType, value)) return this;
return new ImmutableResultRowConverter(this.alias, this.converterType, this.methodName, value);
}
/**
* This instance is equal to all instances of {@code ImmutableResultRowConverter} 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 ImmutableResultRowConverter
&& equalTo(0, (ImmutableResultRowConverter) another);
}
private boolean equalTo(int synthetic, ImmutableResultRowConverter another) {
return Objects.equals(alias, another.alias)
&& Objects.equals(converterType, another.converterType)
&& Objects.equals(methodName, another.methodName)
&& Objects.equals(resultType, another.resultType);
}
/**
* Computes a hash code from attributes: {@code alias}, {@code converterType}, {@code methodName}, {@code resultType}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + Objects.hashCode(alias);
h += (h << 5) + Objects.hashCode(converterType);
h += (h << 5) + Objects.hashCode(methodName);
h += (h << 5) + Objects.hashCode(resultType);
return h;
}
/**
* Prints the immutable value {@code ResultRowConverter} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder("ResultRowConverter{");
if (alias != null) {
builder.append("alias=").append(alias);
}
if (converterType != null) {
if (builder.length() > 19) builder.append(", ");
builder.append("converterType=").append(converterType);
}
if (methodName != null) {
if (builder.length() > 19) builder.append(", ");
builder.append("methodName=").append(methodName);
}
if (resultType != null) {
if (builder.length() > 19) builder.append(", ");
builder.append("resultType=").append(resultType);
}
return builder.append("}").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
*/
@Generated(from = "ResultRowConverter", generator = "Immutables")
@Deprecated
@JsonDeserialize
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements ResultRowConverter {
Optional alias = Optional.empty();
boolean aliasIsSet;
Optional converterType = Optional.empty();
boolean converterTypeIsSet;
Optional methodName = Optional.empty();
boolean methodNameIsSet;
Optional resultType = Optional.empty();
boolean resultTypeIsSet;
@JsonProperty("alias")
public void setAlias(Optional alias) {
this.alias = alias;
this.aliasIsSet = true;
}
@JsonProperty("converterType")
public void setConverterType(Optional converterType) {
this.converterType = converterType;
this.converterTypeIsSet = true;
}
@JsonProperty("methodName")
public void setMethodName(Optional methodName) {
this.methodName = methodName;
this.methodNameIsSet = true;
}
@JsonProperty("resultType")
public void setResultType(Optional resultType) {
this.resultType = resultType;
this.resultTypeIsSet = true;
}
@Override
public Optional alias() { throw new UnsupportedOperationException(); }
@Override
public Optional converterType() { throw new UnsupportedOperationException(); }
@Override
public Optional methodName() { throw new UnsupportedOperationException(); }
@Override
public Optional resultType() { throw new UnsupportedOperationException(); }
@Override
public Optional resultTypeName() { throw new UnsupportedOperationException(); }
@Override
public Optional converterTypeName() { 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 ImmutableResultRowConverter fromJson(Json json) {
ImmutableResultRowConverter.Builder builder = ImmutableResultRowConverter.builder();
if (json.aliasIsSet) {
builder.setAlias(json.alias);
}
if (json.converterTypeIsSet) {
builder.setConverterType(json.converterType);
}
if (json.methodNameIsSet) {
builder.setMethodName(json.methodName);
}
if (json.resultTypeIsSet) {
builder.setResultType(json.resultType);
}
return builder.build();
}
private transient volatile long lazyInitBitmap;
private static final long RESULT_TYPE_NAME_LAZY_INIT_BIT = 0x1L;
private transient Optional resultTypeName;
/**
* {@inheritDoc}
*
* Returns a lazily initialized value of the {@link ResultRowConverter#resultTypeName() resultTypeName} 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 resultTypeName} attribute
*/
@Override
public Optional resultTypeName() {
if ((lazyInitBitmap & RESULT_TYPE_NAME_LAZY_INIT_BIT) == 0) {
synchronized (this) {
if ((lazyInitBitmap & RESULT_TYPE_NAME_LAZY_INIT_BIT) == 0) {
this.resultTypeName = Objects.requireNonNull(ResultRowConverter.super.resultTypeName(), "resultTypeName");
lazyInitBitmap |= RESULT_TYPE_NAME_LAZY_INIT_BIT;
}
}
}
return resultTypeName;
}
private static final long CONVERTER_TYPE_NAME_LAZY_INIT_BIT = 0x2L;
private transient Optional converterTypeName;
/**
* {@inheritDoc}
*
* Returns a lazily initialized value of the {@link ResultRowConverter#converterTypeName() converterTypeName} 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 converterTypeName} attribute
*/
@Override
public Optional converterTypeName() {
if ((lazyInitBitmap & CONVERTER_TYPE_NAME_LAZY_INIT_BIT) == 0) {
synchronized (this) {
if ((lazyInitBitmap & CONVERTER_TYPE_NAME_LAZY_INIT_BIT) == 0) {
this.converterTypeName = Objects.requireNonNull(ResultRowConverter.super.converterTypeName(), "converterTypeName");
lazyInitBitmap |= CONVERTER_TYPE_NAME_LAZY_INIT_BIT;
}
}
}
return converterTypeName;
}
/**
* Creates an immutable copy of a {@link ResultRowConverter} 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 ResultRowConverter instance
*/
public static ImmutableResultRowConverter copyOf(ResultRowConverter instance) {
if (instance instanceof ImmutableResultRowConverter) {
return (ImmutableResultRowConverter) instance;
}
return ImmutableResultRowConverter.builder()
.setAlias(instance.alias())
.setConverterType(instance.converterType())
.setMethodName(instance.methodName())
.setResultType(instance.resultType())
.build();
}
/**
* Creates a builder for {@link ImmutableResultRowConverter ImmutableResultRowConverter}.
*
* ImmutableResultRowConverter.builder()
* .setAlias(String) // optional {@link ResultRowConverter#alias() alias}
* .setConverterType(String) // optional {@link ResultRowConverter#converterType() converterType}
* .setMethodName(String) // optional {@link ResultRowConverter#methodName() methodName}
* .setResultType(String) // optional {@link ResultRowConverter#resultType() resultType}
* .build();
*
* @return A new ImmutableResultRowConverter builder
*/
public static ImmutableResultRowConverter.Builder builder() {
return new ImmutableResultRowConverter.Builder();
}
/**
* Builds instances of type {@link ImmutableResultRowConverter ImmutableResultRowConverter}.
* 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 = "ResultRowConverter", generator = "Immutables")
public static final class Builder {
private static final long OPT_BIT_ALIAS = 0x1L;
private static final long OPT_BIT_CONVERTER_TYPE = 0x2L;
private static final long OPT_BIT_METHOD_NAME = 0x4L;
private static final long OPT_BIT_RESULT_TYPE = 0x8L;
private long optBits;
private String alias;
private String converterType;
private String methodName;
private String resultType;
private Builder() {
}
/**
* Initializes the optional value {@link ResultRowConverter#alias() alias} to alias.
* @param alias The value for alias
* @return {@code this} builder for chained invocation
*/
public final Builder setAlias(String alias) {
checkNotIsSet(aliasIsSet(), "alias");
this.alias = Objects.requireNonNull(alias, "alias");
optBits |= OPT_BIT_ALIAS;
return this;
}
/**
* Initializes the optional value {@link ResultRowConverter#alias() alias} to alias.
* @param alias The value for alias
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("alias")
public final Builder setAlias(Optional alias) {
checkNotIsSet(aliasIsSet(), "alias");
this.alias = alias.orElse(null);
optBits |= OPT_BIT_ALIAS;
return this;
}
/**
* Initializes the optional value {@link ResultRowConverter#converterType() converterType} to converterType.
* @param converterType The value for converterType
* @return {@code this} builder for chained invocation
*/
public final Builder setConverterType(String converterType) {
checkNotIsSet(converterTypeIsSet(), "converterType");
this.converterType = Objects.requireNonNull(converterType, "converterType");
optBits |= OPT_BIT_CONVERTER_TYPE;
return this;
}
/**
* Initializes the optional value {@link ResultRowConverter#converterType() converterType} to converterType.
* @param converterType The value for converterType
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("converterType")
public final Builder setConverterType(Optional converterType) {
checkNotIsSet(converterTypeIsSet(), "converterType");
this.converterType = converterType.orElse(null);
optBits |= OPT_BIT_CONVERTER_TYPE;
return this;
}
/**
* Initializes the optional value {@link ResultRowConverter#methodName() methodName} to methodName.
* @param methodName The value for methodName
* @return {@code this} builder for chained invocation
*/
public final Builder setMethodName(String methodName) {
checkNotIsSet(methodNameIsSet(), "methodName");
this.methodName = Objects.requireNonNull(methodName, "methodName");
optBits |= OPT_BIT_METHOD_NAME;
return this;
}
/**
* Initializes the optional value {@link ResultRowConverter#methodName() methodName} to methodName.
* @param methodName The value for methodName
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("methodName")
public final Builder setMethodName(Optional methodName) {
checkNotIsSet(methodNameIsSet(), "methodName");
this.methodName = methodName.orElse(null);
optBits |= OPT_BIT_METHOD_NAME;
return this;
}
/**
* Initializes the optional value {@link ResultRowConverter#resultType() resultType} to resultType.
* @param resultType The value for resultType
* @return {@code this} builder for chained invocation
*/
public final Builder setResultType(String resultType) {
checkNotIsSet(resultTypeIsSet(), "resultType");
this.resultType = Objects.requireNonNull(resultType, "resultType");
optBits |= OPT_BIT_RESULT_TYPE;
return this;
}
/**
* Initializes the optional value {@link ResultRowConverter#resultType() resultType} to resultType.
* @param resultType The value for resultType
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("resultType")
public final Builder setResultType(Optional resultType) {
checkNotIsSet(resultTypeIsSet(), "resultType");
this.resultType = resultType.orElse(null);
optBits |= OPT_BIT_RESULT_TYPE;
return this;
}
/**
* Builds a new {@link ImmutableResultRowConverter ImmutableResultRowConverter}.
* @return An immutable instance of ResultRowConverter
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableResultRowConverter build() {
return new ImmutableResultRowConverter(alias, converterType, methodName, resultType);
}
private boolean aliasIsSet() {
return (optBits & OPT_BIT_ALIAS) != 0;
}
private boolean converterTypeIsSet() {
return (optBits & OPT_BIT_CONVERTER_TYPE) != 0;
}
private boolean methodNameIsSet() {
return (optBits & OPT_BIT_METHOD_NAME) != 0;
}
private boolean resultTypeIsSet() {
return (optBits & OPT_BIT_RESULT_TYPE) != 0;
}
private static void checkNotIsSet(boolean isSet, String name) {
if (isSet) throw new IllegalStateException("Builder of ResultRowConverter is strict, attribute is already set: ".concat(name));
}
}
}