Class ErpTypeSerializer

java.lang.Object
com.sap.cloud.sdk.s4hana.connectivity.ErpTypeSerializer

@Deprecated public class ErpTypeSerializer extends Object
Deprecated.
This module will be discontinued, along with its classes and methods.
Used for serialization and deserialization of ERP-based types.
  • Constructor Details

    • ErpTypeSerializer

      public ErpTypeSerializer()
      Deprecated.
      Initializes the ErpTypeSerializer with default ERP type converters.
  • Method Details

    • withTypeConverters

      @Nonnull public ErpTypeSerializer withTypeConverters(@Nonnull Iterable<ErpTypeConverter<?>> typeConverters)
      Deprecated.
      Registers the given ErpTypeConverters. Replaces existing converters for already existing types that have been added before.
      Parameters:
      typeConverters - The ERP type converters to be added.
      Returns:
      The same instance.
    • withTypeConverters

      @Nonnull public ErpTypeSerializer withTypeConverters(@Nonnull ErpTypeConverter<?>... typeConverters)
      Deprecated.
      Parameters:
      typeConverters - The ERP type converters to be added.
      Returns:
      The same instance.
    • getTypeConverters

      @Nonnull public Collection<ErpTypeConverter<?>> getTypeConverters()
      Deprecated.
      Gets registered ErpTypeConverters.
      Returns:
      All registered ERP type converters.
    • getTypeConvertersByType

      @Nonnull public Map<Class<?>,ErpTypeConverter<?>> getTypeConvertersByType()
      Deprecated.
      Gets registered ErpTypeConverters for each ErpType.
      Returns:
      The converters for each ERP type.
    • toErp

      @Nonnull public <T> ConvertedObject<String> toErp(@Nullable T object)
      Deprecated.
      Convert given object to an ERP type using a registered ErpTypeConverter.

      Example usage in the SDK ErpTypeSerializer test:

       
       final ErpTypeSerializer serializer = new ErpTypeSerializer();
       assertThat(serializer.toErp(new CostCenter("123")).get()).isEqualTo("0000000123");
       assertThat(serializer.toErp(-123.4d).get()).isEqualTo("123.4-");
       
      Type Parameters:
      T - The generic type.
      Parameters:
      object - The ERP object to serialize.
      Returns:
      A wrapped instance of the serialized object.
    • fromErp

      @Nonnull public <T> ConvertedObject<T> fromErp(@Nullable String erpObject, @Nonnull Class<T> resultType)
      Deprecated.
      Convert a given String based erpObject in the ERP-based representation into an object of resultType. For the conversion, uses a ErpTypeConverter registered for resultType.

      * Example usage in the SDK ErpTypeSerializer test:

       
       assertThat(serializer.fromErp("0000000123", CostCenter.class).get()).isEqualTo(new CostCenter("123"));
       assertThat(serializer.fromErp("123.4 ", Double.class).get()).isEqualTo(123.4d);
       assertThat(serializer.fromErp("123.4-", Double.class).get()).isEqualTo(-123.4d);
       
      Type Parameters:
      T - The generic result type.
      Parameters:
      erpObject - The serialized ERP object.
      resultType - The expected deserialization result type.
      Returns:
      A wrapped instance of the deserialized object.