public static Optional<Object> getAdjacentValue(Type type, Object value, boolean isPrevious)
    {
        if (!type.isOrderable()) {
            throw new IllegalStateException("Type is not orderable: " + type);
        }
        requireNonNull(value, "value is null");

        if (type.equals(BIGINT) || type instanceof TimestampType) {
            return getBigintAdjacentValue(value, isPrevious);
        }

        if (type.equals(INTEGER) || type.equals(DATE)) {
            return getIntegerAdjacentValue(value, isPrevious);
        }

        if (type.equals(SMALLINT)) {
            return getSmallIntAdjacentValue(value, isPrevious);
        }

        if (type.equals(TINYINT)) {
            return getTinyIntAdjacentValue(value, isPrevious);
        }

        if (type.equals(DOUBLE)) {
            return getDoubleAdjacentValue(value, isPrevious);
        }

        if (type.equals(REAL)) {
            return getRealAdjacentValue(value, isPrevious);
        }

        return Optional.empty();
    }
@Test
    public void testNextValueForOtherType()
    {
        assertThat(getAdjacentValue(VARCHAR, "anystr", false))
                .isEmpty();
        assertThat(getAdjacentValue(BOOLEAN, true, false))
                .isEmpty();
        assertThat(getAdjacentValue(TIME, 123L, false))
                .isEmpty();
        assertThat(getAdjacentValue(DecimalType.createDecimalType(8, 2), 12345L, false))
                .isEmpty();
        assertThat(getAdjacentValue(DecimalType.createDecimalType(20, 2),
                encodeScaledValue(new BigDecimal(111111111111111123.45)), false))
                .isEmpty();
    }