Class BaseJodaDatatypeHelper

All Implemented Interfaces:
BaseDatatypeHelper<JavaCodeFragment>, DatatypeHelper
Direct Known Subclasses:
LocalDateHelper, LocalDateTimeHelper, LocalTimeHelper, MonthDayHelper

public class BaseJodaDatatypeHelper extends AbstractTimeHelper
Base class for Joda-Time DatatypeHelper implementations
  • Field Details

  • Constructor Details

    • BaseJodaDatatypeHelper

      public BaseJodaDatatypeHelper(Datatype datatype, String className, String parseMethod)
    • BaseJodaDatatypeHelper

      public BaseJodaDatatypeHelper(String className, String parseMethod)
  • Method Details

    • getJavaClassName

      public String getJavaClassName()
      Description copied from interface: DatatypeHelper
      Returns the qualified Java class name the datatype represents.
    • valueOfExpression

      protected JavaCodeFragment valueOfExpression(String expression)
      Description copied from class: AbstractDatatypeHelper
      This method is supposed to be overridden by subclasses.

      It is used within the newInstanceFromExpression(String) method. It returns a JavaCodeFragment with sourcecode that creates an instance of the datatype's Java class with the given expression.

      If the expression is null the fragment's sourcecode is either the String "null" or the sourcecode to get an instance of the appropriate null object. Preconditions: Expression may not be null or empty. When evaluated the expression must return a String.

      Specified by:
      valueOfExpression in class AbstractDatatypeHelper
    • getToStringExpression

      public JavaCodeFragment getToStringExpression(String fieldName)
      Description copied from interface: DatatypeHelper
      Returns a JavaCodeFragment 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 DatatypeHelpers may override.

      Specified by:
      getToStringExpression in interface BaseDatatypeHelper<JavaCodeFragment>
      Specified by:
      getToStringExpression in interface DatatypeHelper
      Overrides:
      getToStringExpression in class AbstractDatatypeHelper
      Parameters:
      fieldName - the name of the field in the generated class that should be converted to a string
      Returns:
      a JavaCodeFragment containing the toString() code.
    • appendToStringParameter

      protected void appendToStringParameter(JavaCodeFragment fragment)
      Allows subclasses to add parameters to the toString() method.
      Parameters:
      fragment - the fragment to append to
    • nullExpression

      public JavaCodeFragment nullExpression()
      Description copied from class: AbstractDatatypeHelper
      Returns "null". Returns a JavaCodeFragment with sourcecode that is either the String "null" or the sourcecode to get an instance of the appropriate null object.
      Specified by:
      nullExpression in interface BaseDatatypeHelper<JavaCodeFragment>
      Specified by:
      nullExpression in interface DatatypeHelper
      Overrides:
      nullExpression in class AbstractDatatypeHelper