Ejemplo n.º 1
0
 /**
  * Given a Boolean value and return associated "true" object if true; or "false" object if null or
  * false
  *
  * @param val the boolean value to be checked.
  * @param comp associate Component
  * @param ctx bind context for associate {@link Binding} and extra parameter (e.g. true and false)
  * @return the converted "true" object if true; or "false" object if null or false.
  */
 public Object coerceToUi(Object val, Component comp, BindContext ctx) {
   final Object trueObj = ctx.getConverterArg("true");
   final Object falseObj = ctx.getConverterArg("false");
   final Boolean b = (Boolean) val;
   return b != null && b.booleanValue() ? trueObj : falseObj;
 }
Ejemplo n.º 2
0
 /**
  * Given an object value and return whether it is a "true" object.
  *
  * @param val the object to be checked if a true object
  * @param comp associated Component
  * @param ctx bind context for associate {@link Binding} and extra parameter (e.g. true and false)
  * @return the converted Boolean object
  */
 public Object coerceToBean(Object val, Component comp, BindContext ctx) {
   final Object trueObj = ctx.getConverterArg("true");
   return Boolean.valueOf(Objects.equals(val, trueObj));
 }