Interface BaseDatatypeHelper<T extends CodeFragment>

All Known Subinterfaces:
DatatypeHelper, PrimitiveDatatypeHelper
All Known Implementing Classes:
AbstractDatatypeHelper, AbstractPrimitiveDatatypeHelper, AbstractTimeHelper, ArrayOfValueDatatypeHelper, BaseJodaDatatypeHelper, BigDecimalHelper, BooleanHelper, CurrencyHelper, DateHelper, DecimalHelper, DoubleHelper, GenericValueDatatypeHelper, GregorianCalendarAsDateHelper, IntegerHelper, InternationalStringDatatypeHelper, ListOfValueDatatypeHelper, LocalDateHelper, LocalDateHelper, LocalDateTimeHelper, LocalDateTimeHelper, LocalTimeHelper, LocalTimeHelper, LongHelper, MoneyHelper, MonthDayHelper, MonthDayHelper, PrimitiveBooleanHelper, PrimitiveIntegerHelper, PrimitiveLongHelper, StringHelper

public interface BaseDatatypeHelper<T extends CodeFragment>
Interface that defines functionality needed to generate source code for data types.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the data type this is a helper for.
    Returns a CodeFragment containing the code for converting the value (of the given field) to a string representation with respect to its data type.
    Returns a CodeFragment with source code that creates an instance of the data type with the given value.
    Returns a CodeFragment with source code that creates an instance of the data type with the given expression.
    newInstanceFromExpression(String expression, boolean checkForNull)
    Returns a CodeFragment with source code that creates an instance of the data type with the given expression.
    Returns a CodeFragment with source code that is either the String "null" or the source code to get an instance of the appropriate null object.
    void
    Sets the data type this is a helper for.
  • Method Details

    • getDatatype

      Datatype getDatatype()
      Returns the data type this is a helper for.
    • setDatatype

      void setDatatype(Datatype datatype)
      Sets the data type this is a helper for. Introduced to enable setter based dependency injection, needed for example for Eclipse's extension point mechanism.
    • nullExpression

      T nullExpression()
      Returns a CodeFragment with source code that is either the String "null" or the source code to get an instance of the appropriate null object.
    • newInstance

      T newInstance(String value)
      Returns a CodeFragment with source code that creates an instance of the data type with the given value. If the value is null the fragment's source code is either the String "null" or the source code to get an instance of the appropriate null object.
    • newInstanceFromExpression

      T newInstanceFromExpression(String expression)
      Returns a CodeFragment with source code that creates an instance of the data type with the given expression. If the expression is null the fragment's source code is either the String "null" or the source code to get an instance of the appropriate null object. When evaluated the expression must return a string.
      Parameters:
      expression - A source code expression that yields a String. Examples are a constant String like "FOO", a variable like foo or a method call like getÍd().
    • newInstanceFromExpression

      T newInstanceFromExpression(String expression, boolean checkForNull)
      Returns a CodeFragment with source code that creates an instance of the data type with the given expression. If the expression is null the fragment's source code is either the String "null" or the source code to get an instance of the appropriate null object. When evaluated the expression must return a string
      Parameters:
      expression - A source code expression that yields a String. Examples are a constant String like "FOO", a variable like foo or a method call like getÍd().
      checkForNull - true if this helper has to assume that the given expression can yield null or the empty string. Can be used to generate simpler code, if the null check is not necessary.
    • getToStringExpression

      T getToStringExpression(String fieldName)
      Returns a CodeFragment containing the code for converting the value (of the given field) to a string representation with respect to its data type. The String must be built so that it can be read using the valueOf-Expression. If the value is null, the toString-code will yield null as a result.

      The default implementation will call the values toString() method or return null . The default implementation for generic (extensible) data types will call the method defined using setToStringMethodName(). Custom BaseDatatypeHelpers may override.

      Parameters:
      fieldName - the name of the field in the generated class that should be converted to a string
      Returns:
      a CodeFragment containing the toString() code.