io.resys.hdes.client.api.ImmutableStoreState Maven / Gradle / Ivy
package io.resys.hdes.client.api;
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.common.collect.ImmutableMap;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
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 HdesStore.StoreState}.
*
* Use the builder to create immutable instances:
* {@code ImmutableStoreState.builder()}.
*/
@Generated(from = "HdesStore.StoreState", generator = "Immutables")
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
@CheckReturnValue
public final class ImmutableStoreState implements HdesStore.StoreState {
private final ImmutableMap branches;
private final ImmutableMap tags;
private final ImmutableMap flows;
private final ImmutableMap services;
private final ImmutableMap decisions;
private ImmutableStoreState(
ImmutableMap branches,
ImmutableMap tags,
ImmutableMap flows,
ImmutableMap services,
ImmutableMap decisions) {
this.branches = branches;
this.tags = tags;
this.flows = flows;
this.services = services;
this.decisions = decisions;
}
/**
* @return The value of the {@code branches} attribute
*/
@JsonProperty("branches")
@Override
public ImmutableMap getBranches() {
return branches;
}
/**
* @return The value of the {@code tags} attribute
*/
@JsonProperty("tags")
@Override
public ImmutableMap getTags() {
return tags;
}
/**
* @return The value of the {@code flows} attribute
*/
@JsonProperty("flows")
@Override
public ImmutableMap getFlows() {
return flows;
}
/**
* @return The value of the {@code services} attribute
*/
@JsonProperty("services")
@Override
public ImmutableMap getServices() {
return services;
}
/**
* @return The value of the {@code decisions} attribute
*/
@JsonProperty("decisions")
@Override
public ImmutableMap getDecisions() {
return decisions;
}
/**
* Copy the current immutable object by replacing the {@link HdesStore.StoreState#getBranches() branches} map with the specified map.
* Nulls are not permitted as keys or values.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param entries The entries to be added to the branches map
* @return A modified copy of {@code this} object
*/
public final ImmutableStoreState withBranches(Map entries) {
if (this.branches == entries) return this;
ImmutableMap newValue = ImmutableMap.copyOf(entries);
return new ImmutableStoreState(newValue, this.tags, this.flows, this.services, this.decisions);
}
/**
* Copy the current immutable object by replacing the {@link HdesStore.StoreState#getTags() tags} map with the specified map.
* Nulls are not permitted as keys or values.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param entries The entries to be added to the tags map
* @return A modified copy of {@code this} object
*/
public final ImmutableStoreState withTags(Map entries) {
if (this.tags == entries) return this;
ImmutableMap newValue = ImmutableMap.copyOf(entries);
return new ImmutableStoreState(this.branches, newValue, this.flows, this.services, this.decisions);
}
/**
* Copy the current immutable object by replacing the {@link HdesStore.StoreState#getFlows() flows} map with the specified map.
* Nulls are not permitted as keys or values.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param entries The entries to be added to the flows map
* @return A modified copy of {@code this} object
*/
public final ImmutableStoreState withFlows(Map entries) {
if (this.flows == entries) return this;
ImmutableMap newValue = ImmutableMap.copyOf(entries);
return new ImmutableStoreState(this.branches, this.tags, newValue, this.services, this.decisions);
}
/**
* Copy the current immutable object by replacing the {@link HdesStore.StoreState#getServices() services} map with the specified map.
* Nulls are not permitted as keys or values.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param entries The entries to be added to the services map
* @return A modified copy of {@code this} object
*/
public final ImmutableStoreState withServices(Map entries) {
if (this.services == entries) return this;
ImmutableMap newValue = ImmutableMap.copyOf(entries);
return new ImmutableStoreState(this.branches, this.tags, this.flows, newValue, this.decisions);
}
/**
* Copy the current immutable object by replacing the {@link HdesStore.StoreState#getDecisions() decisions} map with the specified map.
* Nulls are not permitted as keys or values.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param entries The entries to be added to the decisions map
* @return A modified copy of {@code this} object
*/
public final ImmutableStoreState withDecisions(Map entries) {
if (this.decisions == entries) return this;
ImmutableMap newValue = ImmutableMap.copyOf(entries);
return new ImmutableStoreState(this.branches, this.tags, this.flows, this.services, newValue);
}
/**
* This instance is equal to all instances of {@code ImmutableStoreState} 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 ImmutableStoreState
&& equalTo((ImmutableStoreState) another);
}
private boolean equalTo(ImmutableStoreState another) {
return branches.equals(another.branches)
&& tags.equals(another.tags)
&& flows.equals(another.flows)
&& services.equals(another.services)
&& decisions.equals(another.decisions);
}
/**
* Computes a hash code from attributes: {@code branches}, {@code tags}, {@code flows}, {@code services}, {@code decisions}.
* @return hashCode value
*/
@Override
public int hashCode() {
@Var int h = 5381;
h += (h << 5) + branches.hashCode();
h += (h << 5) + tags.hashCode();
h += (h << 5) + flows.hashCode();
h += (h << 5) + services.hashCode();
h += (h << 5) + decisions.hashCode();
return h;
}
/**
* Prints the immutable value {@code StoreState} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("StoreState")
.omitNullValues()
.add("branches", branches)
.add("tags", tags)
.add("flows", flows)
.add("services", services)
.add("decisions", decisions)
.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 = "HdesStore.StoreState", generator = "Immutables")
@Deprecated
@SuppressWarnings("Immutable")
@JsonDeserialize
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements HdesStore.StoreState {
@Nullable Map branches = ImmutableMap.of();
@Nullable Map tags = ImmutableMap.of();
@Nullable Map flows = ImmutableMap.of();
@Nullable Map services = ImmutableMap.of();
@Nullable Map decisions = ImmutableMap.of();
@JsonProperty("branches")
public void setBranches(Map branches) {
this.branches = branches;
}
@JsonProperty("tags")
public void setTags(Map tags) {
this.tags = tags;
}
@JsonProperty("flows")
public void setFlows(Map flows) {
this.flows = flows;
}
@JsonProperty("services")
public void setServices(Map services) {
this.services = services;
}
@JsonProperty("decisions")
public void setDecisions(Map decisions) {
this.decisions = decisions;
}
@Override
public Map getBranches() { throw new UnsupportedOperationException(); }
@Override
public Map getTags() { throw new UnsupportedOperationException(); }
@Override
public Map getFlows() { throw new UnsupportedOperationException(); }
@Override
public Map getServices() { throw new UnsupportedOperationException(); }
@Override
public Map getDecisions() { 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 ImmutableStoreState fromJson(Json json) {
ImmutableStoreState.Builder builder = ImmutableStoreState.builder();
if (json.branches != null) {
builder.putAllBranches(json.branches);
}
if (json.tags != null) {
builder.putAllTags(json.tags);
}
if (json.flows != null) {
builder.putAllFlows(json.flows);
}
if (json.services != null) {
builder.putAllServices(json.services);
}
if (json.decisions != null) {
builder.putAllDecisions(json.decisions);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link HdesStore.StoreState} 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 StoreState instance
*/
public static ImmutableStoreState copyOf(HdesStore.StoreState instance) {
if (instance instanceof ImmutableStoreState) {
return (ImmutableStoreState) instance;
}
return ImmutableStoreState.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link ImmutableStoreState ImmutableStoreState}.
*
* ImmutableStoreState.builder()
* .putBranches|putAllBranches(String => io.resys.hdes.client.api.HdesStore.StoreEntity) // {@link HdesStore.StoreState#getBranches() branches} mappings
* .putTags|putAllTags(String => io.resys.hdes.client.api.HdesStore.StoreEntity) // {@link HdesStore.StoreState#getTags() tags} mappings
* .putFlows|putAllFlows(String => io.resys.hdes.client.api.HdesStore.StoreEntity) // {@link HdesStore.StoreState#getFlows() flows} mappings
* .putServices|putAllServices(String => io.resys.hdes.client.api.HdesStore.StoreEntity) // {@link HdesStore.StoreState#getServices() services} mappings
* .putDecisions|putAllDecisions(String => io.resys.hdes.client.api.HdesStore.StoreEntity) // {@link HdesStore.StoreState#getDecisions() decisions} mappings
* .build();
*
* @return A new ImmutableStoreState builder
*/
public static ImmutableStoreState.Builder builder() {
return new ImmutableStoreState.Builder();
}
/**
* Builds instances of type {@link ImmutableStoreState ImmutableStoreState}.
* 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 = "HdesStore.StoreState", generator = "Immutables")
@NotThreadSafe
public static final class Builder {
private ImmutableMap.Builder branches = ImmutableMap.builder();
private ImmutableMap.Builder tags = ImmutableMap.builder();
private ImmutableMap.Builder flows = ImmutableMap.builder();
private ImmutableMap.Builder services = ImmutableMap.builder();
private ImmutableMap.Builder decisions = ImmutableMap.builder();
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code StoreState} 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 Builder from(HdesStore.StoreState instance) {
Objects.requireNonNull(instance, "instance");
putAllBranches(instance.getBranches());
putAllTags(instance.getTags());
putAllFlows(instance.getFlows());
putAllServices(instance.getServices());
putAllDecisions(instance.getDecisions());
return this;
}
/**
* Put one entry to the {@link HdesStore.StoreState#getBranches() branches} map.
* @param key The key in the branches map
* @param value The associated value in the branches map
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder putBranches(String key, HdesStore.StoreEntity value) {
this.branches.put(key, value);
return this;
}
/**
* Put one entry to the {@link HdesStore.StoreState#getBranches() branches} map. Nulls are not permitted
* @param entry The key and value entry
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder putBranches(Map.Entry entry) {
this.branches.put(entry);
return this;
}
/**
* Sets or replaces all mappings from the specified map as entries for the {@link HdesStore.StoreState#getBranches() branches} map. Nulls are not permitted
* @param entries The entries that will be added to the branches map
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("branches")
public final Builder branches(Map entries) {
this.branches = ImmutableMap.builder();
return putAllBranches(entries);
}
/**
* Put all mappings from the specified map as entries to {@link HdesStore.StoreState#getBranches() branches} map. Nulls are not permitted
* @param entries The entries that will be added to the branches map
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder putAllBranches(Map entries) {
this.branches.putAll(entries);
return this;
}
/**
* Put one entry to the {@link HdesStore.StoreState#getTags() tags} map.
* @param key The key in the tags map
* @param value The associated value in the tags map
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder putTags(String key, HdesStore.StoreEntity value) {
this.tags.put(key, value);
return this;
}
/**
* Put one entry to the {@link HdesStore.StoreState#getTags() tags} map. Nulls are not permitted
* @param entry The key and value entry
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder putTags(Map.Entry entry) {
this.tags.put(entry);
return this;
}
/**
* Sets or replaces all mappings from the specified map as entries for the {@link HdesStore.StoreState#getTags() tags} map. Nulls are not permitted
* @param entries The entries that will be added to the tags map
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("tags")
public final Builder tags(Map entries) {
this.tags = ImmutableMap.builder();
return putAllTags(entries);
}
/**
* Put all mappings from the specified map as entries to {@link HdesStore.StoreState#getTags() tags} map. Nulls are not permitted
* @param entries The entries that will be added to the tags map
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder putAllTags(Map entries) {
this.tags.putAll(entries);
return this;
}
/**
* Put one entry to the {@link HdesStore.StoreState#getFlows() flows} map.
* @param key The key in the flows map
* @param value The associated value in the flows map
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder putFlows(String key, HdesStore.StoreEntity value) {
this.flows.put(key, value);
return this;
}
/**
* Put one entry to the {@link HdesStore.StoreState#getFlows() flows} map. Nulls are not permitted
* @param entry The key and value entry
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder putFlows(Map.Entry entry) {
this.flows.put(entry);
return this;
}
/**
* Sets or replaces all mappings from the specified map as entries for the {@link HdesStore.StoreState#getFlows() flows} map. Nulls are not permitted
* @param entries The entries that will be added to the flows map
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("flows")
public final Builder flows(Map entries) {
this.flows = ImmutableMap.builder();
return putAllFlows(entries);
}
/**
* Put all mappings from the specified map as entries to {@link HdesStore.StoreState#getFlows() flows} map. Nulls are not permitted
* @param entries The entries that will be added to the flows map
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder putAllFlows(Map entries) {
this.flows.putAll(entries);
return this;
}
/**
* Put one entry to the {@link HdesStore.StoreState#getServices() services} map.
* @param key The key in the services map
* @param value The associated value in the services map
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder putServices(String key, HdesStore.StoreEntity value) {
this.services.put(key, value);
return this;
}
/**
* Put one entry to the {@link HdesStore.StoreState#getServices() services} map. Nulls are not permitted
* @param entry The key and value entry
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder putServices(Map.Entry entry) {
this.services.put(entry);
return this;
}
/**
* Sets or replaces all mappings from the specified map as entries for the {@link HdesStore.StoreState#getServices() services} map. Nulls are not permitted
* @param entries The entries that will be added to the services map
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("services")
public final Builder services(Map entries) {
this.services = ImmutableMap.builder();
return putAllServices(entries);
}
/**
* Put all mappings from the specified map as entries to {@link HdesStore.StoreState#getServices() services} map. Nulls are not permitted
* @param entries The entries that will be added to the services map
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder putAllServices(Map entries) {
this.services.putAll(entries);
return this;
}
/**
* Put one entry to the {@link HdesStore.StoreState#getDecisions() decisions} map.
* @param key The key in the decisions map
* @param value The associated value in the decisions map
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder putDecisions(String key, HdesStore.StoreEntity value) {
this.decisions.put(key, value);
return this;
}
/**
* Put one entry to the {@link HdesStore.StoreState#getDecisions() decisions} map. Nulls are not permitted
* @param entry The key and value entry
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder putDecisions(Map.Entry entry) {
this.decisions.put(entry);
return this;
}
/**
* Sets or replaces all mappings from the specified map as entries for the {@link HdesStore.StoreState#getDecisions() decisions} map. Nulls are not permitted
* @param entries The entries that will be added to the decisions map
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("decisions")
public final Builder decisions(Map entries) {
this.decisions = ImmutableMap.builder();
return putAllDecisions(entries);
}
/**
* Put all mappings from the specified map as entries to {@link HdesStore.StoreState#getDecisions() decisions} map. Nulls are not permitted
* @param entries The entries that will be added to the decisions map
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder putAllDecisions(Map entries) {
this.decisions.putAll(entries);
return this;
}
/**
* Builds a new {@link ImmutableStoreState ImmutableStoreState}.
* @return An immutable instance of StoreState
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableStoreState build() {
return new ImmutableStoreState(branches.build(), tags.build(), flows.build(), services.build(), decisions.build());
}
}
}