Interface EdmPrimitiveType

All Superinterfaces:
EdmNamed, EdmType
All Known Subinterfaces:
EdmEnumType, EdmTypeDefinition

public interface EdmPrimitiveType extends EdmType
EdmPrimitiveType is a primitive type as defined in the Entity Data Model (EDM).
There are methods to convert EDM primitive types from and to Java objects, respectively. The following Java types are supported:
EDM primitive typeJava types
Binarybyte[], Byte[]
BooleanBoolean
ByteShort, Byte, Integer, Long, BigInteger
DateCalendar, Date, Timestamp, Time, Long
DateTimeOffsetTimestamp, Calendar, Date, Time, Long
DecimalBigDecimal, BigInteger, Double, Float, Byte, Short, Integer, Long
DoubleDouble, Float, BigDecimal, Byte, Short, Integer, Long
DurationBigDecimal, BigInteger, Double, Float, Byte, Short, Integer, Long
GuidUUID
Int16Short, Byte, Integer, Long, BigInteger
Int32Integer, Byte, Short, Long, BigInteger
Int64Long, Byte, Short, Integer, BigInteger
SByteByte, Short, Integer, Long, BigInteger
SingleFloat, Double, BigDecimal, Byte, Short, Integer, Long
StringString
TimeOfDayCalendar, Date, Timestamp, Time, Long

The first Java type is the default type for the respective EDM primitive type.

For all EDM primitive types, the Nullable facet is taken into account. For Binary and String, MaxLength is also applicable. For String, the facet Unicode is considered additionally. The EDM primitive types DateTimeOffset, Decimal, Duration, and TimeOfDay can have a Precision facet. Additionally, Decimal can have the facet Scale.

  • Field Details

  • Method Details

    • isCompatible

      boolean isCompatible(EdmPrimitiveType primitiveType)
      Checks type compatibility.
      Parameters:
      primitiveType - the EdmPrimitiveType to be tested for compatibility
      Returns:
      true if the provided type is compatible to this type
    • getDefaultType

      Class<?> getDefaultType()
      Returns the default Java type for this EDM primitive type as described in the documentation of EdmPrimitiveType.
      Returns:
      the default Java type
    • validate

      boolean validate(String value, Boolean isNullable, Integer maxLength, Integer precision, Integer scale, Boolean isUnicode)
      Validates literal value.
      Parameters:
      value - the literal value
      isNullable - whether the null value is allowed
      maxLength - the maximum length
      precision - the precision
      scale - the scale
      isUnicode - whether non-ASCII characters are allowed (relevant only for Edm.String)
      Returns:
      true if the validation is successful
    • valueOfString

      <T> T valueOfString(String value, Boolean isNullable, Integer maxLength, Integer precision, Integer scale, Boolean isUnicode, Class<T> returnType) throws EdmPrimitiveTypeException
      Converts literal representation of value to system data type.
      Parameters:
      value - the literal representation of value
      isNullable - whether the null value is allowed
      maxLength - the maximum length
      precision - the precision
      scale - the scale
      isUnicode - whether non-ASCII characters are allowed (relevant only for Edm.String)
      returnType - the class of the returned value; it must be one of the list in the documentation of EdmPrimitiveType
      Returns:
      the value as an instance of the class the parameter returnType indicates
      Throws:
      EdmPrimitiveTypeException
    • valueToString

      String valueToString(Object value, Boolean isNullable, Integer maxLength, Integer precision, Integer scale, Boolean isUnicode) throws EdmPrimitiveTypeException
      Converts system data type to literal representation of value.

      Returns null if value is null and null is an allowed value.

      Parameters:
      value - the Java value as Object; its type must be one of the list in the documentation of EdmPrimitiveType
      isNullable - whether the null value is allowed
      maxLength - the maximum length
      precision - the precision
      scale - the scale
      isUnicode - whether non-ASCII characters are allowed (relevant only for Edm.String)
      Returns:
      literal representation as String
      Throws:
      EdmPrimitiveTypeException
    • toUriLiteral

      String toUriLiteral(String literal)
      Converts default literal representation to URI literal representation.

      Returns null if the literal is null. Does not perform any validation.

      Parameters:
      literal - the literal in default representation
      Returns:
      URI literal representation as String
    • fromUriLiteral

      String fromUriLiteral(String literal) throws EdmPrimitiveTypeException
      Converts URI literal representation to default literal representation.

      Returns null if the literal is null. Checks the presence of a required prefix and of required surrounding quotation marks but does not perform any further validation.

      Parameters:
      literal - the literal in URI representation
      Returns:
      default literal representation as String
      Throws:
      EdmPrimitiveTypeException - if a required prefix or required surrounding quotation marks are missing
    • validateDecimals

      default boolean validateDecimals(String value, Boolean isNullable, Integer maxLength, Integer precision, String scale, Boolean isUnicode)
      Validates literal value for Decimal values in V4.01
      Parameters:
      value - the literal value
      isNullable - whether the null value is allowed
      maxLength - the maximum length
      precision - the precision
      scale - the scale (could be variable or floating)
      isUnicode - whether non-ASCII characters are allowed (relevant only for Edm.String)
      Returns:
      true if the validation is successful