ilog.rules.res.session.rawdata
Annotation Type TypeConverter
-
@Retention(value=RUNTIME) @Target(value=TYPE) public @interface TypeConverter
Annotation that indicates the target class is a type converter class. A type converter class should have:- Non-parameter constructor
- A public void init(Map<String, String> props) method
- One and only one pair of public methods convertToTarget and convertToSource that meet the following conditions:
- Has return value and a parameter
- The return value and parameter of the two methods are matching
Code example:
The following code show how to implements a converter between String and boolean.
@TypeConverter
public class StringBooleanConverter { protected String trueExp; protected String falseExp; public void init(Mapprops) { this.trueExp = props.get("cobol_bool_true"); this.falseExp = props.get("cobol_bool_false"); } public synchronized boolean convertToTarget(String source) { return trueExp.equals(source); } public synchronized String convertToSource(boolean target) { return target ? trueExp : falseExp; } }