io.deephaven.api.object.UnionObjectBase Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of deephaven-table-api Show documentation
Show all versions of deephaven-table-api Show documentation
The Deephaven table operations API
The newest version!
//
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
//
package io.deephaven.api.object;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
abstract class UnionObjectBase implements UnionObject {
private static final Set> BOXED_TYPES = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
Boolean.class,
Character.class,
Byte.class,
Short.class,
Integer.class,
Long.class,
Float.class,
Double.class)));
static boolean isBoxedPrimitive(Class> clazz) {
return BOXED_TYPES.contains(clazz);
}
@Override
public final Object unwrap() {
return visit(Unwrap.INSTANCE);
}
@Override
public final Number number() {
return expect(Number.class);
}
@Override
public final boolean booleanValue() {
return expect(Boolean.class);
}
@Override
public final char charValue() {
return expect(Character.class);
}
@Override
public final byte byteValue() {
return number().byteValue();
}
@Override
public final short shortValue() {
return number().shortValue();
}
@Override
public final int intValue() {
return number().intValue();
}
@Override
public final long longValue() {
return number().longValue();
}
@Override
public final float floatValue() {
return number().floatValue();
}
@Override
public final double doubleValue() {
return number().doubleValue();
}
@Override
public final T expect(Class clazz) {
return visit(new Expect<>(clazz));
}
enum Unwrap implements Visitor