io.deephaven.tuple.generated.ByteObjectCharTuple 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.ByteComparisons;
import io.deephaven.util.compare.CharComparisons;
import io.deephaven.util.compare.ObjectComparisons;
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 byte, Object, and char elements.
*
Generated by io.deephaven.replicators.TupleCodeGenerator.
*/
public class ByteObjectCharTuple implements Comparable, Externalizable, StreamingExternalizable, CanonicalizableTuple {
private static final long serialVersionUID = 1L;
private byte element1;
private Object element2;
private char element3;
private transient int cachedHashCode;
public ByteObjectCharTuple(
final byte element1,
final Object element2,
final char element3
) {
initialize(
element1,
element2,
element3
);
}
/** Public no-arg constructor for {@link Externalizable} support only. Application code should not use this! **/
public ByteObjectCharTuple() {
}
private void initialize(
final byte element1,
final Object element2,
final char element3
) {
this.element1 = element1;
this.element2 = element2;
this.element3 = element3;
cachedHashCode = ((31 +
Byte.hashCode(element1)) * 31 +
Objects.hashCode(element2)) * 31 +
Character.hashCode(element3);
}
public final byte getFirstElement() {
return element1;
}
public final Object getSecondElement() {
return element2;
}
public final char 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 ByteObjectCharTuple typedOther = (ByteObjectCharTuple) other;
// @formatter:off
return element1 == typedOther.element1 &&
ObjectComparisons.eq(element2, typedOther.element2) &&
element3 == typedOther.element3;
// @formatter:on
}
@Override
public final int compareTo(@NotNull final ByteObjectCharTuple other) {
if (this == other) {
return 0;
}
int comparison;
// @formatter:off
return 0 != (comparison = ByteComparisons.compare(element1, other.element1)) ? comparison :
0 != (comparison = ObjectComparisons.compare(element2, other.element2)) ? comparison :
CharComparisons.compare(element3, other.element3);
// @formatter:on
}
@Override
public void writeExternal(@NotNull final ObjectOutput out) throws IOException {
out.writeByte(element1);
out.writeObject(element2);
out.writeChar(element3);
}
@Override
public void readExternal(@NotNull final ObjectInput in) throws IOException, ClassNotFoundException {
initialize(
in.readByte(),
in.readObject(),
in.readChar()
);
}
@Override
public void writeExternalStreaming(@NotNull final ObjectOutput out, @NotNull final TIntObjectMap cachedWriters) throws IOException {
out.writeByte(element1);
StreamingExternalizable.writeObjectElement(out, cachedWriters, 1, element2);
out.writeChar(element3);
}
@Override
public void readExternalStreaming(@NotNull final ObjectInput in, @NotNull final TIntObjectMap cachedReaders) throws Exception {
initialize(
in.readByte(),
StreamingExternalizable.readObjectElement(in, cachedReaders, 1),
in.readChar()
);
}
@Override
public String toString() {
return "ByteObjectCharTuple{" +
element1 + ", " +
element2 + ", " +
element3 + '}';
}
@Override
public ByteObjectCharTuple canonicalize(@NotNull final UnaryOperator