Package org.faktorips.codegen
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 TypeMethodDescriptionReturns the data type this is a helper for.getToStringExpression(String fieldName) Returns aCodeFragmentcontaining the code for converting the value (of the given field) to a string representation with respect to its data type.newInstance(String value) Returns a CodeFragment with source code that creates an instance of the data type with the given value.newInstanceFromExpression(String expression) 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.voidsetDatatype(Datatype datatype) Sets the data type this is a helper for.
-
Method Details
-
getDatatype
Datatype getDatatype()Returns the data type this is a helper for. -
setDatatype
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
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
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 likefooor a method call likegetÍd().
-
newInstanceFromExpression
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 likefooor a method call likegetÍd().checkForNull-trueif this helper has to assume that the given expression can yieldnullor the empty string. Can be used to generate simpler code, if the null check is not necessary.
-
getToStringExpression
Returns aCodeFragmentcontaining 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 isnull, the toString-code will yieldnullas 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(). CustomBaseDatatypeHelpers may override.- Parameters:
fieldName- the name of the field in the generated class that should be converted to a string- Returns:
- a
CodeFragmentcontaining the toString() code.
-