Package org.faktorips.codegen.dthelpers
Class ListOfValueDatatypeHelper
java.lang.Object
org.faktorips.codegen.dthelpers.AbstractDatatypeHelper
org.faktorips.codegen.dthelpers.ListOfValueDatatypeHelper
- All Implemented Interfaces:
BaseDatatypeHelper<JavaCodeFragment>,DatatypeHelper
A helper class for lists of values. There is no data type for lists though. The data type
specified in the constructor is the data type of the elements in the list.
valueOfExpression(String) expects a list as expression and returns code that creates a
copy of that list. newInstance(String) returns code that creates an empty list. The
given value will be ignored.- Author:
- Stefan Widmaier
-
Field Summary
Fields inherited from interface org.faktorips.codegen.DatatypeHelper
BIG_DECIMAL, BOOLEAN, DECIMAL, INTEGER, LONG, MONEY, PRIMITIVE_BOOLEAN, PRIMITIVE_INTEGER, STRING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateCastExpression(String bound) Returns aJavaCodeFragmentwith anew value instance, adding a cast to the value's data type in case the value is empty to avoid problems with generics.Returns theValueDatatypeof the elements in the list.Returns the datatype this is a helper for.Returns code for a list-variable or -argument declarations. e.g.Returns the qualified Java class name the datatype represents.getRangeJavaClassName(boolean useTypesafeCollections) Returns the qualified Java class name of the range class of the datatype this is a helper for.Returns the qualified Java class name for the value datatype.newInstance(String expression) Returns code that creates a list where the given expression is used as a constructor argument.newRangeInstance(JavaCodeFragment lowerBoundExp, JavaCodeFragment upperBoundExp, JavaCodeFragment stepExp, JavaCodeFragment containsNullExp, boolean useTypesafeCollections) Returns aJavaCodeFragmentcontaining the source code to create a new instance of a type specific range.newValueInstance(String value) Returns aJavaCodeFragmentfor the value datatype.referenceOrSafeCopyIfNeccessary(String expression) If this is a helper for a mutable data type (like GregorianCalendar for example) this method return the code fragment that creates a copy of the given expression.protected JavaCodeFragmentvalueOfExpression(String expression) Expects a list as expression and returns code that creates a copy of that list.Methods inherited from class org.faktorips.codegen.dthelpers.AbstractDatatypeHelper
getToStringExpression, newEnumValueSetInstance, newEnumValueSetInstance, newInstanceFromExpression, newInstanceFromExpression, newSafeCopy, nullExpression, setDatatype
-
Constructor Details
-
ListOfValueDatatypeHelper
-
-
Method Details
-
getDatatype
Description copied from interface:DatatypeHelperReturns the datatype this is a helper for.- Specified by:
getDatatypein interfaceBaseDatatypeHelper<JavaCodeFragment>- Specified by:
getDatatypein interfaceDatatypeHelper- Overrides:
getDatatypein classAbstractDatatypeHelper
-
getBasicDatatype
Returns theValueDatatypeof the elements in the list. -
getBasicJavaClassName
-
getJavaClassName
Description copied from interface:DatatypeHelperReturns the qualified Java class name the datatype represents. -
valueOfExpression
Expects a list as expression and returns code that creates a copy of that list. This method is supposed to be overridden by subclasses.It is used within the
newInstanceFromExpression(String)method. It returns aJavaCodeFragmentwith sourcecode that creates an instance of the datatype's Java class with the given expression.If the expression is
nullthe 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:
valueOfExpressionin classAbstractDatatypeHelper
-
newInstance
Returns code that creates a list where the given expression is used as a constructor argument. Returns aJavaCodeFragmentwith sourcecode that creates an instance of the datatype's Java class with the given value. If the value is null the fragment's sourcecode is either the String "null" or the sourcecode to get an instance of the appropriate null object. -
referenceOrSafeCopyIfNeccessary
Description copied from interface:DatatypeHelperIf this is a helper for a mutable data type (like GregorianCalendar for example) this method return the code fragment that creates a copy of the given expression. For immutable data types this method returns the expression unmodified.- Specified by:
referenceOrSafeCopyIfNeccessaryin interfaceDatatypeHelper- Overrides:
referenceOrSafeCopyIfNeccessaryin classAbstractDatatypeHelper- Parameters:
expression- An expression (as Java sourcecode)- Returns:
- s. above
-
getDeclarationJavaTypeFragment
Returns code for a list-variable or -argument declarations. e.g.List<ElementJavaClassName>. -
getValueSetJavaClassName
Description copied from interface:DatatypeHelperReturns the qualified Java class name for the value datatype. This is the same asDatatypeHelper.getJavaClassName()for most datatypes but might differ for example forListtyped values, where the datatype of the list's contents is returned. -
getRangeJavaClassName
Description copied from interface:DatatypeHelperReturns the qualified Java class name of the range class of the datatype this is a helper for.- Specified by:
getRangeJavaClassNamein interfaceDatatypeHelper- Overrides:
getRangeJavaClassNamein classAbstractDatatypeHelper
-
newRangeInstance
public JavaCodeFragment newRangeInstance(JavaCodeFragment lowerBoundExp, JavaCodeFragment upperBoundExp, JavaCodeFragment stepExp, JavaCodeFragment containsNullExp, boolean useTypesafeCollections) Description copied from interface:DatatypeHelperReturns aJavaCodeFragmentcontaining the source code to create a new instance of a type specific range.- Specified by:
newRangeInstancein interfaceDatatypeHelper- Overrides:
newRangeInstancein classAbstractDatatypeHelper- Parameters:
lowerBoundExp- the lower bound expression of the range. Can benullto indicate that the lower bound is openupperBoundExp- the upper bound expression of the range. Can benullto indicate that the upper bound is open.stepExp- the minimum increment expression for values within the lower and upper bounds. Can benullto indicate that this is a continuous range.containsNullExp- the containsNull expression- Returns:
- the code fragment to create a new range instance. Can be null to indicate that a range is not supported.
-
createCastExpression
Description copied from interface:DatatypeHelperReturns aJavaCodeFragmentwith anew value instance, adding a cast to the value's data type in case the value is empty to avoid problems with generics.- Specified by:
createCastExpressionin interfaceDatatypeHelper- Overrides:
createCastExpressionin classAbstractDatatypeHelper- Parameters:
bound- the String representation of a value of thisdatatype- Returns:
- a
JavaCodeFragmentcontaining the code to create (and cast) the value
-
newValueInstance
Description copied from interface:DatatypeHelperReturns aJavaCodeFragmentfor the value datatype. This is the same asDatatypeHelper.newInstance(String)for most datatypes but might differ for example forListtyped values, where the datatype of the list's contents is returned.
-