1- // SPDX-FileCopyrightText: Copyright 2018-2024 Mark Rotteveel
1+ // SPDX-FileCopyrightText: Copyright 2018-2026 Mark Rotteveel
22// SPDX-License-Identifier: LGPL-2.1-or-later
33package org .firebirdsql .jdbc .field ;
44
1313import org .firebirdsql .jdbc .FBDriverNotCapableException ;
1414import org .jspecify .annotations .NonNull ;
1515import org .jspecify .annotations .NullMarked ;
16+ import org .jspecify .annotations .Nullable ;
1617
1718import java .math .BigDecimal ;
1819import java .math .BigInteger ;
@@ -32,7 +33,7 @@ final class FBDecfloatField<T extends Decimal<T>> extends FBField {
3233 private static final BigDecimal BD_MIN_LONG = BigDecimal .valueOf (Long .MIN_VALUE );
3334
3435 private final @ NonNull Class <T > decimalType ;
35- private final @ NonNull DecimalHandling <T > decimalHandling ;
36+ private final @ NonNull DecimalHandling <@ NonNull T > decimalHandling ;
3637
3738 @ NullMarked
3839 FBDecfloatField (FieldDescriptor fieldDescriptor , FieldDataProvider dataProvider , int requiredType ,
@@ -210,23 +211,24 @@ public void setString(String value) throws SQLException {
210211
211212 @ SuppressWarnings ("unchecked" )
212213 @ NullMarked
213- private DecimalHandling <T > getDecimalHandling (FieldDescriptor fieldDescriptor , Class <T > decimalType )
214+ private DecimalHandling <@ NonNull T > getDecimalHandling (FieldDescriptor fieldDescriptor , Class <T > decimalType )
214215 throws FBDriverNotCapableException {
215216 if (decimalType == Decimal64 .class && fieldDescriptor .isFbType (ISCConstants .SQL_DEC16 )) {
216- return (DecimalHandling <T >) Decimal64Handling .INSTANCE ;
217+ return (DecimalHandling <@ NonNull T >) Decimal64Handling .INSTANCE ;
217218 } else if (decimalType == Decimal128 .class && fieldDescriptor .isFbType (ISCConstants .SQL_DEC34 )) {
218- return (DecimalHandling <T >) Decimal128Handling .INSTANCE ;
219+ return (DecimalHandling <@ NonNull T >) Decimal128Handling .INSTANCE ;
219220 } else {
220221 throw new FBDriverNotCapableException ("Unsupported type " + decimalType .getName () + " and/or field type " +
221222 fieldDescriptor .getType ());
222223 }
223224 }
224225
226+ @ NullMarked
225227 private interface DecimalHandling <T extends Decimal <T >> {
226228
227- byte [] encode (FieldDescriptor fieldDescriptor , T value );
229+ byte @ Nullable [] encode (FieldDescriptor fieldDescriptor , @ Nullable T value );
228230
229- T decode (FieldDescriptor fieldDescriptor , byte [] fieldData );
231+ @ Nullable T decode (FieldDescriptor fieldDescriptor , byte @ Nullable [] fieldData );
230232
231233 T valueOf (double value );
232234
@@ -236,17 +238,18 @@ private interface DecimalHandling<T extends Decimal<T>> {
236238
237239 }
238240
241+ @ NullMarked
239242 private static final class Decimal64Handling implements DecimalHandling <Decimal64 > {
240243
241244 private static final Decimal64Handling INSTANCE = new Decimal64Handling ();
242245
243246 @ Override
244- public byte [] encode (FieldDescriptor fieldDescriptor , Decimal64 value ) {
247+ public byte @ Nullable [] encode (FieldDescriptor fieldDescriptor , @ Nullable Decimal64 value ) {
245248 return fieldDescriptor .getDatatypeCoder ().encodeDecimal64 (value );
246249 }
247250
248251 @ Override
249- public Decimal64 decode (FieldDescriptor fieldDescriptor , byte [] fieldData ) {
252+ public @ Nullable Decimal64 decode (FieldDescriptor fieldDescriptor , byte @ Nullable [] fieldData ) {
250253 return fieldDescriptor .getDatatypeCoder ().decodeDecimal64 (fieldData );
251254 }
252255
@@ -267,17 +270,18 @@ public Decimal64 valueOf(BigDecimal value) {
267270
268271 }
269272
273+ @ NullMarked
270274 private static final class Decimal128Handling implements DecimalHandling <Decimal128 > {
271275
272276 private static final Decimal128Handling INSTANCE = new Decimal128Handling ();
273277
274278 @ Override
275- public byte [] encode (FieldDescriptor fieldDescriptor , Decimal128 value ) {
279+ public byte @ Nullable [] encode (FieldDescriptor fieldDescriptor , @ Nullable Decimal128 value ) {
276280 return fieldDescriptor .getDatatypeCoder ().encodeDecimal128 (value );
277281 }
278282
279283 @ Override
280- public Decimal128 decode (FieldDescriptor fieldDescriptor , byte [] fieldData ) {
284+ public @ Nullable Decimal128 decode (FieldDescriptor fieldDescriptor , byte @ Nullable [] fieldData ) {
281285 return fieldDescriptor .getDatatypeCoder ().decodeDecimal128 (fieldData );
282286 }
283287
0 commit comments