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

net.yudichev.jiotty.connector.owntracks.OwnTracksUpdate Maven / Gradle / Ivy

The newest version!
package net.yudichev.jiotty.connector.owntracks;

import com.google.common.base.MoreObjects;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import java.util.ArrayList;
import java.util.List;
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 BaseOwnTracksUpdate}.
 * 

* Use the builder to create immutable instances: * {@code OwnTracksUpdate.builder()}. * Use the static factory method to create immutable instances: * {@code OwnTracksUpdate.of()}. */ @Generated(from = "BaseOwnTracksUpdate", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class OwnTracksUpdate implements BaseOwnTracksUpdate { private final DeviceKey deviceKey; private final T payload; private OwnTracksUpdate(DeviceKey deviceKey, T payload) { this.deviceKey = Objects.requireNonNull(deviceKey, "deviceKey"); this.payload = Objects.requireNonNull(payload, "payload"); } private OwnTracksUpdate(OwnTracksUpdate original, DeviceKey deviceKey, T payload) { this.deviceKey = deviceKey; this.payload = payload; } /** * @return The value of the {@code deviceKey} attribute */ @Override public DeviceKey deviceKey() { return deviceKey; } /** * @return The value of the {@code payload} attribute */ @Override public T payload() { return payload; } /** * Copy the current immutable object by setting a value for the {@link OwnTracksUpdate#deviceKey() deviceKey} 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 deviceKey * @return A modified copy of the {@code this} object */ public final OwnTracksUpdate withDeviceKey(DeviceKey value) { if (this.deviceKey == value) return this; DeviceKey newValue = Objects.requireNonNull(value, "deviceKey"); return new OwnTracksUpdate<>(this, newValue, this.payload); } /** * Copy the current immutable object by setting a value for the {@link OwnTracksUpdate#payload() payload} 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 payload * @return A modified copy of the {@code this} object */ public final OwnTracksUpdate withPayload(T value) { if (this.payload == value) return this; T newValue = Objects.requireNonNull(value, "payload"); return new OwnTracksUpdate<>(this, this.deviceKey, newValue); } /** * This instance is equal to all instances of {@code OwnTracksUpdate} 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 OwnTracksUpdate && equalTo(0, (OwnTracksUpdate) another); } private boolean equalTo(int synthetic, OwnTracksUpdate another) { return deviceKey.equals(another.deviceKey) && payload.equals(another.payload); } /** * Computes a hash code from attributes: {@code deviceKey}, {@code payload}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + deviceKey.hashCode(); h += (h << 5) + payload.hashCode(); return h; } /** * Prints the immutable value {@code OwnTracksUpdate} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("OwnTracksUpdate") .omitNullValues() .add("deviceKey", deviceKey) .add("payload", payload) .toString(); } /** * Construct a new immutable {@code OwnTracksUpdate} instance. * @param generic parameter T * @param deviceKey The value for the {@code deviceKey} attribute * @param payload The value for the {@code payload} attribute * @return An immutable OwnTracksUpdate instance */ public static OwnTracksUpdate of(DeviceKey deviceKey, T payload) { return new OwnTracksUpdate<>(deviceKey, payload); } /** * Creates an immutable copy of a {@link BaseOwnTracksUpdate} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param generic parameter T * @param instance The instance to copy * @return A copied immutable OwnTracksUpdate instance */ static OwnTracksUpdate copyOf(BaseOwnTracksUpdate instance) { if (instance instanceof OwnTracksUpdate) { return (OwnTracksUpdate) instance; } return OwnTracksUpdate.builder() .from(instance) .build(); } /** * Creates a builder for {@link OwnTracksUpdate OwnTracksUpdate}. *

   * OwnTracksUpdate.&lt;T&gt;builder()
   *    .setDeviceKey(net.yudichev.jiotty.connector.owntracks.DeviceKey) // required {@link OwnTracksUpdate#deviceKey() deviceKey}
   *    .setPayload(T) // required {@link OwnTracksUpdate#payload() payload}
   *    .build();
   * 
* @param generic parameter T * @return A new OwnTracksUpdate builder */ public static OwnTracksUpdate.Builder builder() { return new OwnTracksUpdate.Builder<>(); } /** * Builds instances of type {@link OwnTracksUpdate OwnTracksUpdate}. * 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 = "BaseOwnTracksUpdate", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_DEVICE_KEY = 0x1L; private static final long INIT_BIT_PAYLOAD = 0x2L; private long initBits = 0x3L; private @Nullable DeviceKey deviceKey; private @Nullable T payload; private Builder() { } /** * Fill a builder with attribute values from the provided {@code OwnTracksUpdate} 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 */ public final Builder from(OwnTracksUpdate instance) { return from((BaseOwnTracksUpdate) instance); } /** * Copy abstract value type {@code BaseOwnTracksUpdate} instance into builder. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue final Builder from(BaseOwnTracksUpdate instance) { Objects.requireNonNull(instance, "instance"); setDeviceKey(instance.deviceKey()); setPayload(instance.payload()); return this; } /** * Initializes the value for the {@link OwnTracksUpdate#deviceKey() deviceKey} attribute. * @param deviceKey The value for deviceKey * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder setDeviceKey(DeviceKey deviceKey) { this.deviceKey = Objects.requireNonNull(deviceKey, "deviceKey"); initBits &= ~INIT_BIT_DEVICE_KEY; return this; } /** * Initializes the value for the {@link OwnTracksUpdate#payload() payload} attribute. * @param payload The value for payload * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder setPayload(T payload) { this.payload = Objects.requireNonNull(payload, "payload"); initBits &= ~INIT_BIT_PAYLOAD; return this; } /** * Builds a new {@link OwnTracksUpdate OwnTracksUpdate}. * @return An immutable instance of OwnTracksUpdate * @throws java.lang.IllegalStateException if any required attributes are missing */ public OwnTracksUpdate build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new OwnTracksUpdate<>(null, deviceKey, payload); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_DEVICE_KEY) != 0) attributes.add("deviceKey"); if ((initBits & INIT_BIT_PAYLOAD) != 0) attributes.add("payload"); return "Cannot build OwnTracksUpdate, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy