A wrapper type for SQL:2016 standard DECFLOAT data types. The wrapper represents DECFLOAT #data() in serialised string form. A CAST(NULL AS DECFLOAT) value is represented by a null reference of type Decfloat, not as data() == null</cod
| 53 | * returning <code>NULL</code> from {@link Result} and {@link Record} methods. |
| 54 | */ |
| 55 | public final class Decfloat extends Number implements Data { |
| 56 | |
| 57 | private final String data; |
| 58 | private transient BigDecimal coefficient; |
| 59 | private transient int exponent; |
| 60 | private transient Special special; |
| 61 | |
| 62 | private Decfloat(String data) { |
| 63 | this.data = String.valueOf(data); |
| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | @NotNull |
| 68 | public final String data() { |
| 69 | return data; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Create a new {@link Decfloat} instance from string data input. |
| 74 | */ |
| 75 | @NotNull |
| 76 | public static final Decfloat valueOf(String data) { |
| 77 | return new Decfloat(data); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Create a new {@link Decfloat} instance from string data input. |
| 82 | * <p> |
| 83 | * This is the same as {@link #valueOf(String)}, but it can be static |
| 84 | * imported. |
| 85 | */ |
| 86 | @NotNull |
| 87 | public static final Decfloat decfloat(String data) { |
| 88 | return new Decfloat(data); |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Create a new {@link Decfloat} instance from string data input, or |
| 93 | * <code>null</code> if the input is <code>null</code>. |
| 94 | */ |
| 95 | @Nullable |
| 96 | public static final Decfloat decfloatOrNull(String data) { |
| 97 | return data == null ? null : decfloat(data); |
| 98 | } |
| 99 | |
| 100 | // ------------------------------------------------------------------------ |
| 101 | // The Float API |
| 102 | // ------------------------------------------------------------------------ |
| 103 | |
| 104 | /** |
| 105 | * Check whether this value is the {@link Decfloat} equivalent of {@link Double#NaN}. |
| 106 | */ |
| 107 | public final boolean isNaN() { |
| 108 | parse(); |
| 109 | return special == Special.NAN; |
| 110 | } |
| 111 | |
| 112 | /** |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…