Class ODataTypeUtils

java.lang.Object
com.sap.cds.services.impl.odata.utils.ODataTypeUtils

public class ODataTypeUtils extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.sap.cds.reflect.CdsBaseType
    getCdsType(com.sap.cds.reflect.CdsStructuredType structuredType, com.sap.cds.ql.cqn.CqnElementRef ref)
    This method determines the CDS type of the reference ref belonging to the structuredType
    static boolean
    isArrayedSimpleType(com.sap.cds.reflect.CdsType type)
     
    static boolean
    isArrayedStructuredType(com.sap.cds.reflect.CdsType type)
     
    static boolean
    isSimpleType(com.sap.cds.reflect.CdsType type)
     
    static boolean
    isStructuredType(com.sap.cds.reflect.CdsType type)
     
    static Object
    toCdsType(Object value, com.sap.cds.reflect.CdsBaseType type)
    This method converts the value to the correct Java type defined in type.
    static Iterable<?>
    toCdsTypes(com.sap.cds.reflect.CdsBaseType type, Iterable<? extends Object> data)
     
    static <T extends Map<String, Object>>
    T
    toCdsTypes(com.sap.cds.reflect.CdsStructuredType structuredType, T data)
     
    static Object
    toCloudSdkType(Object value, com.sap.cds.reflect.CdsBaseType type, com.sap.cloud.sdk.datamodel.odata.client.ODataProtocol protocol)
    Converts the Object to the correct Java type to be used with Cloud SDK.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ODataTypeUtils

      public ODataTypeUtils()
  • Method Details

    • toCloudSdkType

      public static Object toCloudSdkType(Object value, com.sap.cds.reflect.CdsBaseType type, com.sap.cloud.sdk.datamodel.odata.client.ODataProtocol protocol)
      Converts the Object to the correct Java type to be used with Cloud SDK.
      Parameters:
      value - the value to convert
      type - the CdsBaseType
      protocol - the ODataProtocol
      Returns:
      the value converted to the correct type
    • getCdsType

      public static com.sap.cds.reflect.CdsBaseType getCdsType(com.sap.cds.reflect.CdsStructuredType structuredType, com.sap.cds.ql.cqn.CqnElementRef ref)
      This method determines the CDS type of the reference ref belonging to the structuredType
      Parameters:
      structuredType - the CdsStructuredType
      ref - the CqnElementRef
      Returns:
      the CDS type if it could be determined
    • toCdsTypes

      public static <T extends Map<String, Object>> T toCdsTypes(com.sap.cds.reflect.CdsStructuredType structuredType, T data)
    • toCdsTypes

      public static <T extends Iterable<? extends Map<String, Object>>> T toCdsTypes(com.sap.cds.reflect.CdsStructuredType structuredType, T data)
      Converts the values in data to the correct Java types according to the respective CdsBaseType defined in the CDS model.
      Type Parameters:
      T - the data type
      Parameters:
      structuredType - the CdsStructuredType
      data - the data to convert
      Returns:
      The converted data
    • toCdsTypes

      public static Iterable<?> toCdsTypes(com.sap.cds.reflect.CdsBaseType type, Iterable<? extends Object> data)
    • toCdsType

      public static Object toCdsType(Object value, com.sap.cds.reflect.CdsBaseType type)
      This method converts the value to the correct Java type defined in type.
      Parameters:
      value - the value to convert
      type - the CdsBaseType to convert to
      Returns:
      the converted value
      Throws:
      ErrorStatusException - in case the value cannot be converted
    • isSimpleType

      public static boolean isSimpleType(com.sap.cds.reflect.CdsType type)
    • isArrayedSimpleType

      public static boolean isArrayedSimpleType(com.sap.cds.reflect.CdsType type)
    • isStructuredType

      public static boolean isStructuredType(com.sap.cds.reflect.CdsType type)
    • isArrayedStructuredType

      public static boolean isArrayedStructuredType(com.sap.cds.reflect.CdsType type)