io.deephaven.tuple.generated.ShortCharObjectTuple Maven / Gradle / Ivy
Show all versions of deephaven-engine-tuple Show documentation
package io.deephaven.tuple.generated;
import gnu.trove.map.TIntObjectMap;
import io.deephaven.tuple.CanonicalizableTuple;
import io.deephaven.tuple.serialization.SerializationUtils;
import io.deephaven.tuple.serialization.StreamingExternalizable;
import io.deephaven.util.compare.CharComparisons;
import io.deephaven.util.compare.ObjectComparisons;
import io.deephaven.util.compare.ShortComparisons;
import org.jetbrains.annotations.NotNull;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Objects;
import java.util.function.UnaryOperator;
/**
* 3-Tuple (triple) key class composed of short, char, and Object elements.
*
Generated by io.deephaven.replicators.TupleCodeGenerator.
*/
public class ShortCharObjectTuple implements Comparable, Externalizable, StreamingExternalizable, CanonicalizableTuple {
private static final long serialVersionUID = 1L;
private short element1;
private char element2;
private Object element3;
private transient int cachedHashCode;
public ShortCharObjectTuple(
final short element1,
final char element2,
final Object element3
) {
initialize(
element1,
element2,
element3
);
}
/** Public no-arg constructor for {@link Externalizable} support only. Application code should not use this! **/
public ShortCharObjectTuple() {
}
private void initialize(
final short element1,
final char element2,
final Object element3
) {
this.element1 = element1;
this.element2 = element2;
this.element3 = element3;
cachedHashCode = ((31 +
Short.hashCode(element1)) * 31 +
Character.hashCode(element2)) * 31 +
Objects.hashCode(element3);
}
public final short getFirstElement() {
return element1;
}
public final char getSecondElement() {
return element2;
}
public final Object getThirdElement() {
return element3;
}
@Override
public final int hashCode() {
return cachedHashCode;
}
@Override
public final boolean equals(final Object other) {
if (this == other) {
return true;
}
if (other == null || getClass() != other.getClass()) {
return false;
}
final ShortCharObjectTuple typedOther = (ShortCharObjectTuple) other;
// @formatter:off
return element1 == typedOther.element1 &&
element2 == typedOther.element2 &&
ObjectComparisons.eq(element3, typedOther.element3);
// @formatter:on
}
@Override
public final int compareTo(@NotNull final ShortCharObjectTuple other) {
if (this == other) {
return 0;
}
int comparison;
// @formatter:off
return 0 != (comparison = ShortComparisons.compare(element1, other.element1)) ? comparison :
0 != (comparison = CharComparisons.compare(element2, other.element2)) ? comparison :
ObjectComparisons.compare(element3, other.element3);
// @formatter:on
}
@Override
public void writeExternal(@NotNull final ObjectOutput out) throws IOException {
out.writeShort(element1);
out.writeChar(element2);
out.writeObject(element3);
}
@Override
public void readExternal(@NotNull final ObjectInput in) throws IOException, ClassNotFoundException {
initialize(
in.readShort(),
in.readChar(),
in.readObject()
);
}
@Override
public void writeExternalStreaming(@NotNull final ObjectOutput out, @NotNull final TIntObjectMap cachedWriters) throws IOException {
out.writeShort(element1);
out.writeChar(element2);
StreamingExternalizable.writeObjectElement(out, cachedWriters, 2, element3);
}
@Override
public void readExternalStreaming(@NotNull final ObjectInput in, @NotNull final TIntObjectMap cachedReaders) throws Exception {
initialize(
in.readShort(),
in.readChar(),
StreamingExternalizable.readObjectElement(in, cachedReaders, 2)
);
}
@Override
public String toString() {
return "ShortCharObjectTuple{" +
element1 + ", " +
element2 + ", " +
element3 + '}';
}
@Override
public ShortCharObjectTuple canonicalize(@NotNull final UnaryOperator