Class NumberConverter

java.lang.Object
org.fastnate.generator.converter.NumberConverter
All Implemented Interfaces:
ValueConverter<Number>

public class NumberConverter extends Object implements ValueConverter<Number>
Converts a numeric value to a SQL expression.
Author:
Tobias Liefke
  • Constructor Details

    • NumberConverter

      public NumberConverter(Class<? extends Number> type)
      Creates a new instance of NumberConverter.
      Parameters:
      type - the type of the number
      Throws:
      ModelException - if the String constructor is missing from the given number class
  • Method Details

    • getExpression

      public ColumnExpression getExpression(Number value, GeneratorContext context)
      Description copied from interface: ValueConverter
      Builds the expression for writing the given value into an SQL clause.
      Specified by:
      getExpression in interface ValueConverter<Number>
      Parameters:
      value - the current value
      context - the current context (contains the database dialect).
      Returns:
      the expression (that is including surrounding ' for string literals)
    • getExpression

      public ColumnExpression getExpression(String defaultValue, GeneratorContext context)
      Description copied from interface: ValueConverter
      Builds the expression for writing the default value into an SQL clause.
      Specified by:
      getExpression in interface ValueConverter<Number>
      Parameters:
      defaultValue - the default value, as given in an DefaultValue expression
      context - the current context (contains the database dialect).
      Returns:
      the expression (that is including surrounding ' for string literals)