Module jakarta.el
Package jakarta.el

Class TypeConverter

java.lang.Object
jakarta.el.ELResolver
jakarta.el.TypeConverter

public abstract class TypeConverter extends ELResolver
A convenient class for writing an ELResolver to do custom type conversions.

For example, to convert a String to an instance of MyDate, one can write

 
     ELProcessor elp = new ELProcessor();
     elp.getELManager().addELResolver(new TypeConverter() {
         Object convertToType(ELContext context, Object obj, Class<?> type) {
             if ((obj instanceof String) && type == MyDate.class) {
                 context.setPropertyResolved(obj, type);
                 return (obj == null)? null: new MyDate(obj.toString());
             }
             return null;
         }
      };
 
 
Since:
Jakarta Expression Language 3.0