Class NumericType

java.lang.Object
dev.frostlake.types.DataType
dev.frostlake.types.NumericType
All Implemented Interfaces:
Serializable

public class NumericType extends DataType
See Also:
  • Field Details

  • Constructor Details

    • NumericType

      public NumericType(String name, int precision, int scale)
  • Method Details

    • getPrecision

      public int getPrecision()
    • getScale

      public int getScale()
    • parseValue

      public Object parseValue(String value)
      Specified by:
      parseValue in class DataType
    • formatValue

      public String formatValue(Object value)
      Specified by:
      formatValue in class DataType
    • isCompatible

      public boolean isCompatible(DataType other)
      Specified by:
      isCompatible in class DataType
    • getCommonType

      public DataType getCommonType(DataType other)
      Specified by:
      getCommonType in class DataType
    • getSize

      public int getSize()
      Specified by:
      getSize in class DataType
    • isApproximate

      public static boolean isApproximate(DataType type)
      Whether a type is one of the APPROXIMATE numeric spellings, which carry no precision and scale.

      Live-verified on every metadata surface: a FLOAT column is {"type":"REAL"} in SHOW COLUMNS with no numbers beside it, and leaves NUMERIC_PRECISION and NUMERIC_SCALE NULL in INFORMATION_SCHEMA. The nominal pair these constants carry is an engine-internal placeholder and must not be published to a client as though it were declared.

      Parameters:
      type - the type to test
      Returns:
      true for FLOAT and its aliases
    • isApproximateName

      public static boolean isApproximateName(String name)
      Whether a type NAME is one of the approximate spellings — for a caller that has the name and not the type, such as a driver reading column metadata off the wire.
      Parameters:
      name - the declared type's name
      Returns:
      true for FLOAT and its aliases