Class TypeUtil


  • public class TypeUtil
    extends Object
    • Method Detail

      • parseOrCast

        public static Object parseOrCast​(org.dmg.pmml.DataType dataType,
                                         Object value)
        Throws:
        IllegalArgumentException - If the value is a String, and it cannot be parsed to the requested representation.
        TypeCheckException - If the value is an Object other than String, and it cannot be cast to the requested representation.
      • parse

        public static Object parse​(org.dmg.pmml.DataType dataType,
                                   String value)
        Throws:
        IllegalArgumentException - If the String representation of the value cannot be parsed to the requested representation.
      • equals

        public static boolean equals​(org.dmg.pmml.DataType dataType,
                                     Object value,
                                     Object referenceValue)
      • getDataType

        public static org.dmg.pmml.DataType getDataType​(Object value)
        Returns:
        The data type of the value.
      • getDataType

        public static org.dmg.pmml.DataType getDataType​(Collection<?> values)
      • getCommonDataType

        public static org.dmg.pmml.DataType getCommonDataType​(org.dmg.pmml.DataType left,
                                                              org.dmg.pmml.DataType right)
        Returns:
        The least restrictive data type of two numeric data types.
        See Also:
        DataType.INTEGER, DataType.FLOAT, DataType.DOUBLE
      • getOpType

        public static org.dmg.pmml.OpType getOpType​(org.dmg.pmml.DataType dataType)
      • cast

        public static Object cast​(org.dmg.pmml.DataType dataType,
                                  Object value)
        Throws:
        TypeCheckException - If the value cannot be cast to the requested representation.
      • cast

        public static <V> V cast​(Class<? extends V> clazz,
                                 Object value)
      • getConstantDataType

        public static org.dmg.pmml.DataType getConstantDataType​(Object value)
      • getConstantDataType

        public static org.dmg.pmml.DataType getConstantDataType​(String value)