Package org.faktorips.codegen
Class ConversionCodeGenerator<T extends CodeFragment>
java.lang.Object
org.faktorips.codegen.ConversionCodeGenerator<T>
- All Implemented Interfaces:
ConversionMatrix
public class ConversionCodeGenerator<T extends CodeFragment>
extends Object
implements ConversionMatrix
The ConversionCodeGenerator extends the ConversionMatrix with the ability to generate the Java
source code needed to convert the value of a given data type to another (if the conversion is
possible).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(SingleConversionCg<T> conversion) booleancanConvert(Datatype from, Datatype to) Returns true if a value of datatype from can be converted into one of datatype to.getConversionCode(Datatype from, Datatype to, T fromValue) static final ConversionCodeGenerator<JavaCodeFragment>Returns a default ConversionCodeGenerator that contains the following conversions.
-
Constructor Details
-
ConversionCodeGenerator
public ConversionCodeGenerator()
-
-
Method Details
-
getDefault
Returns a default ConversionCodeGenerator that contains the following conversions.- Primitive boolean to Boolean
- Boolean to primitive boolean
- Primitive int to Integer
- Integer to primitive int
- Primitive int to Decimal
- Integer to Decimal
- Any data type to String
-
add
-
canConvert
Description copied from interface:ConversionMatrixReturns true if a value of datatype from can be converted into one of datatype to. If datatype from and to are equal, the method returns true.- Specified by:
canConvertin interfaceConversionMatrix
-
getConversionCode
Returns the Java source code that converts a value ofDatatypefromto a value ofDatatypetoif possible. Returns null if the conversion is not possible.- Parameters:
from- The data type to convert from.to- The data type to convert to.fromValue- A Java source code fragment containing an expression that evaluates to a value ofDatatypefrom.
-