private static List buildBinders()

in cloud-spanner-r2dbc/src/main/java/com/google/cloud/spanner/r2dbc/v2/ClientLibraryBinder.java [39:82]


  private static List<ClientLibraryTypeBinder> buildBinders() {
    List<ClientLibraryTypeBinder> binders = new ArrayList<>();
    binders.add(
        new SingleTypeBinder<>(Integer.class,
            (binder, val) -> binder.to(longFromInteger(val))));
    binders.add(new SingleTypeBinder<>(Long.class, ValueBinder::to));
    binders.add(new SingleTypeBinder<>(Double.class, ValueBinder::to));
    binders.add(new SingleTypeBinder<>(Boolean.class, ValueBinder::to));
    binders.add(new SingleTypeBinder<>(ByteArray.class, ValueBinder::to));
    binders.add(new SingleTypeBinder<>(Date.class, ValueBinder::to));
    binders.add(new SingleTypeBinder<>(String.class, ValueBinder::to));
    binders.add(new SingleTypeBinder<>(Timestamp.class, ValueBinder::to));
    binders.add(new SingleTypeBinder<>(BigDecimal.class, ValueBinder::to));
    binders.add(
        new SingleTypeBinder<>(
            JsonWrapper.class,
            (binder, val) -> binder.to(val == null ? Value.json(null) : val.getJsonVal())));

    // Primitive arrays
    binders.add(new SingleTypeBinder<>(boolean[].class, ValueBinder::toBoolArray));
    binders.add(new SingleTypeBinder<>(long[].class, ValueBinder::toInt64Array));
    binders.add(new SingleTypeBinder<>(double[].class, ValueBinder::toFloat64Array));

    // Primitive arrays that have to expand element size to 64 bits to match Spanner types.
    binders.add(new SingleTypeBinder<>(
        int[].class, (binder, val) -> binder.toInt64Array(toLongArray(val))));
    binders.add(new SingleTypeBinder<>(
        float[].class, (binder, val) -> binder.toFloat64Array(toDoubleArray(val))));

    // Object arrays
    binders.add(new ArrayToIterableBinder<>(Boolean[].class, ValueBinder::toBoolArray));
    binders.add(new ArrayToIterableBinder<>(ByteArray[].class, ValueBinder::toBytesArray));
    binders.add(new ArrayToIterableBinder<>(Date[].class, ValueBinder::toDateArray));
    binders.add(new ArrayToIterableBinder<>(String[].class, ValueBinder::toStringArray));
    binders.add(new ArrayToIterableBinder<>(Timestamp[].class, ValueBinder::toTimestampArray));
    binders.add(new ArrayToIterableBinder<>(BigDecimal[].class, ValueBinder::toNumericArray));

    // STRUCT not supported

    // Binds collections to Spanner array, if an element type hint is available.
    binders.add(new IterableBinder());

    return binders;
  }