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:
      1. Has return value and a parameter
      2. 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(Map props) {
          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;
       }
     }
     
     

© Copyright IBM Corp. 1987, 2020