private NumberConverter getNumberConverter(Converter existingConverter) {

    if (existingConverter != null) {
      if (!(existingConverter instanceof NumberConverter)) {
        throw WidgetProcessorException.newException(
            "Unable to set number attributes on a " + existingConverter.getClass());
      }

      return (NumberConverter) existingConverter;
    }

    // In case the application defines its own one

    FacesContext context = FacesContext.getCurrentInstance();
    NumberConverter numberConverter =
        (NumberConverter) context.getApplication().createConverter(Number.class);

    if (numberConverter != null) {
      return numberConverter;
    }

    // The JSF default

    return new NumberConverter();
  }
  private DateTimeConverter getDateTimeConverter(Converter existingConverter) {

    if (existingConverter != null) {
      if (!(existingConverter instanceof DateTimeConverter)) {
        throw WidgetProcessorException.newException(
            "Unable to set date/time attributes on a " + existingConverter.getClass());
      }

      return (DateTimeConverter) existingConverter;
    }

    // In case the application defines its own one

    FacesContext context = FacesContext.getCurrentInstance();
    DateTimeConverter dateTimeConverter =
        (DateTimeConverter) context.getApplication().createConverter(Date.class);

    if (dateTimeConverter != null) {
      return dateTimeConverter;
    }

    // The JSF default

    return new DateTimeConverter();
  }
    public boolean isValid(Object value) {

      if (value == null) {
        return !mNumberType.isPrimitive();
      }

      // Range check

      if (byte.class.equals(mNumberType) || Byte.class.equals(mNumberType)) {
        if (mMinimum != null && (Byte) value < (Byte) mMinimum) {
          return false;
        }
        if (mMaximum != null && (Byte) value > (Byte) mMaximum) {
          return false;
        }
      } else if (short.class.equals(mNumberType) || Short.class.equals(mNumberType)) {
        if (mMinimum != null && (Short) value < (Short) mMinimum) {
          return false;
        }
        if (mMaximum != null && (Short) value > (Short) mMaximum) {
          return false;
        }
      } else if (int.class.equals(mNumberType) || Integer.class.equals(mNumberType)) {
        if (mMinimum != null && ((Number) value).intValue() < (Integer) mMinimum) {
          return false;
        }
        if (mMaximum != null && ((Number) value).intValue() > (Integer) mMaximum) {
          return false;
        }
      } else if (long.class.equals(mNumberType) || Long.class.equals(mNumberType)) {
        if (mMinimum != null && (Long) value < (Long) mMinimum) {
          return false;
        }
        if (mMaximum != null && (Long) value > (Long) mMaximum) {
          return false;
        }
      } else if (float.class.equals(mNumberType) || Float.class.equals(mNumberType)) {
        if (mMinimum != null && (Float) value < (Float) mMinimum) {
          return false;
        }
        if (mMaximum != null && (Float) value > (Float) mMaximum) {
          return false;
        }
      } else if (double.class.equals(mNumberType) || Double.class.equals(mNumberType)) {
        if (mMinimum != null && (Double) value < (Double) mMinimum) {
          return false;
        }
        if (mMaximum != null && (Double) value > (Double) mMaximum) {
          return false;
        }
      } else {
        throw WidgetProcessorException.newException(
            mNumberType + " cannot be validated within min/max");
      }

      return true;
    }
  public Component processWidget(
      final Component component,
      String elementName,
      Map<String, String> attributes,
      VaadinMetawidget metawidget) {

    // Only bind to non-read-only Actions

    if (!ACTION.equals(elementName)) {
      return component;
    }

    if (component instanceof Stub) {
      return component;
    }

    if (!(component instanceof Button)) {
      throw WidgetProcessorException.newException(
          "ReflectionBindingProcessor only supports binding actions to Buttons");
    }

    if (WidgetBuilderUtils.isReadOnly(attributes)) {
      return component;
    }

    if (metawidget == null) {
      return component;
    }

    Object toInspect = metawidget.getToInspect();

    if (toInspect == null) {
      return component;
    }

    Button button = (Button) component;

    // Traverse to the last Object...

    String[] names = PathUtils.parsePath(metawidget.getPath()).getNamesAsArray();

    for (String name : names) {
      toInspect = ClassUtils.getProperty(toInspect, name);

      if (toInspect == null) {
        return component;
      }
    }

    // ...and wire it up

    final Object fireActionOn = toInspect;
    final Class<?> fireActionOnClass = fireActionOn.getClass();
    final String actionName = attributes.get(NAME);

    button.addListener(
        new ClickListener() {

          public void buttonClick(ClickEvent event) {

            try {
              Method method = fireActionOnClass.getMethod(actionName, (Class[]) null);
              method.invoke(fireActionOn, (Object[]) null);
            } catch (Exception e) {
              throw WidgetProcessorException.newException(e);
            }
          }
        });

    return component;
  }