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

io.deephaven.engine.table.impl.MutableColumnSourceGetDefaults Maven / Gradle / Ivy

There is a newer version: 0.37.1
Show newest version
/**
 * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
 */
package io.deephaven.engine.table.impl;

import io.deephaven.engine.table.ColumnSource;
import io.deephaven.time.DateTimeUtils;
import org.jetbrains.annotations.Nullable;

import java.time.Instant;

import static io.deephaven.util.type.TypeUtils.box;

/**
 * Defaulted interfaces for various mutable {@link ColumnSource} types, in order to avoid having defaults at higher
 * levels in the class hierarchy.
 */
public final class MutableColumnSourceGetDefaults {

    /**
     * Default interface for mutable Object {@link ColumnSource} implementations.
     */
    public interface ForObject
            extends ColumnSourceGetDefaults.ForObject, MutableColumnSource {

        @Override
        default Boolean getPrevBoolean(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default byte getPrevByte(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default char getPrevChar(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default double getPrevDouble(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default float getPrevFloat(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default int getPrevInt(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default long getPrevLong(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default short getPrevShort(final long rowKey) {
            throw new UnsupportedOperationException();
        }
    }

    /**
     * Default interface for mutable Boolean {@link ColumnSource} implementations.
     */
    public interface ForBoolean extends ColumnSourceGetDefaults.ForBoolean, MutableColumnSource {

        @Override
        default Boolean getPrevBoolean(final long rowKey) {
            return getPrev(rowKey);
        }

        @Override
        default byte getPrevByte(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default char getPrevChar(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default double getPrevDouble(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default float getPrevFloat(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default int getPrevInt(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default long getPrevLong(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default short getPrevShort(final long rowKey) {
            throw new UnsupportedOperationException();
        }
    }

    /**
     * Default interface for mutable byte {@link ColumnSource} implementations.
     */
    public interface ForByte extends ColumnSourceGetDefaults.ForByte, MutableColumnSource {

        @Override
        default Byte getPrev(final long rowKey) {
            return box(getPrevByte(rowKey));
        }

        @Override
        default Boolean getPrevBoolean(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default char getPrevChar(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default double getPrevDouble(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default float getPrevFloat(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default int getPrevInt(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default long getPrevLong(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default short getPrevShort(final long rowKey) {
            throw new UnsupportedOperationException();
        }
    }

    /**
     * Default interface for mutable char {@link ColumnSource} implementations.
     */
    public interface ForChar extends ColumnSourceGetDefaults.ForChar, MutableColumnSource {

        @Override
        default Character getPrev(final long rowKey) {
            return box(getPrevChar(rowKey));
        }

        @Override
        default Boolean getPrevBoolean(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default byte getPrevByte(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default double getPrevDouble(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default float getPrevFloat(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default int getPrevInt(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default long getPrevLong(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default short getPrevShort(final long rowKey) {
            throw new UnsupportedOperationException();
        }
    }

    /**
     * Default interface for mutable double {@link ColumnSource} implementations.
     */
    public interface ForDouble extends ColumnSourceGetDefaults.ForDouble, MutableColumnSource {

        @Override
        default Double getPrev(final long rowKey) {
            return box(getPrevDouble(rowKey));
        }

        @Override
        default Boolean getPrevBoolean(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default byte getPrevByte(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default char getPrevChar(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default float getPrevFloat(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default int getPrevInt(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default long getPrevLong(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default short getPrevShort(final long rowKey) {
            throw new UnsupportedOperationException();
        }
    }

    /**
     * Default interface for mutable float {@link ColumnSource} implementations.
     */
    public interface ForFloat extends ColumnSourceGetDefaults.ForFloat, MutableColumnSource {

        @Override
        default Float getPrev(final long rowKey) {
            return box(getPrevFloat(rowKey));
        }

        @Override
        default Boolean getPrevBoolean(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default byte getPrevByte(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default char getPrevChar(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default double getPrevDouble(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default int getPrevInt(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default long getPrevLong(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default short getPrevShort(final long rowKey) {
            throw new UnsupportedOperationException();
        }
    }

    /**
     * Default interface for mutable int {@link ColumnSource} implementations.
     */
    public interface ForInt extends ColumnSourceGetDefaults.ForInt, MutableColumnSource {

        @Override
        default Integer getPrev(final long rowKey) {
            return box(getPrevInt(rowKey));
        }

        @Override
        default Boolean getPrevBoolean(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default byte getPrevByte(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default char getPrevChar(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default double getPrevDouble(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default float getPrevFloat(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default long getPrevLong(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default short getPrevShort(final long rowKey) {
            throw new UnsupportedOperationException();
        }
    }

    /**
     * Default interface for mutable long-backed {@link ColumnSource} implementations.
     */
    public interface LongBacked
            extends ColumnSourceGetDefaults.LongBacked, MutableColumnSource {

        default Boolean getPrevBoolean(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default byte getPrevByte(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default char getPrevChar(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default double getPrevDouble(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default float getPrevFloat(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default int getPrevInt(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default short getPrevShort(final long rowKey) {
            throw new UnsupportedOperationException();
        }
    }

    /**
     * Default interface for mutable long {@link ColumnSource} implementations.
     */
    public interface ForLong extends ColumnSourceGetDefaults.ForLong, LongBacked {

        @Override
        default Long getPrev(final long rowKey) {
            return box(getPrevLong(rowKey));
        }
    }

    /**
     * Default interface for mutable {@link Instant} {@link ColumnSource} implementations.
     */
    public interface ForLongAsInstant extends ColumnSourceGetDefaults.ForLongAsInstant, LongBacked {
        @Nullable
        @Override
        default Instant getPrev(long rowKey) {
            return DateTimeUtils.epochNanosToInstant(getPrevLong(rowKey));
        }
    }

    /**
     * Default interface for mutable short {@link ColumnSource} implementations.
     */
    public interface ForShort extends ColumnSourceGetDefaults.ForShort, MutableColumnSource {

        @Override
        default Short getPrev(final long rowKey) {
            return box(getPrevShort(rowKey));
        }

        @Override
        default Boolean getPrevBoolean(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default byte getPrevByte(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default char getPrevChar(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default double getPrevDouble(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default float getPrevFloat(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default int getPrevInt(final long rowKey) {
            throw new UnsupportedOperationException();
        }

        @Override
        default long getPrevLong(final long rowKey) {
            throw new UnsupportedOperationException();
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy