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

io.deephaven.tuple.generated.ObjectLongLongTuple Maven / Gradle / Ivy

There is a newer version: 0.36.1
Show newest version
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.LongComparisons;
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 Object, long, and long elements. *

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