@Override public boolean isEmpty() { return getFieldValue() == null; }
/** * Gets the current value of the field. * * <p> * This is the visible, modified and possible invalid value the user have * entered to the field. * </p> * * <p> * Note that the object returned is compatible with getType(). For example, * if the type is String, this returns Strings even when the underlying * datasource is of some other type. In order to access the converted value, * use {@link #getConvertedValue()} and to access the value of the property * data source, use {@link Property#getValue()} for the property data * source. * </p> * * <p> * Since Vaadin 7.0, no implicit conversions between other data types and * String are performed, but a converter is used if set. * </p> * * @return the current value of the field. */ @Override public T getValue() { return getFieldValue(); }
/** * Returns the current value (as returned by {@link #getValue()}) converted * to the data source type. * <p> * This returns the same as {@link AbstractField#getValue()} if no converter * has been set. The value is not necessarily the same as the data source * value e.g. if the field is in buffered mode and has been modified. * </p> * * @return The converted value that is compatible with the data source type */ public Object getConvertedValue() { return convertToModel(getFieldValue()); }
/** * Checks the validity of the Field. * * A field is invalid if it is set as required (using * {@link #setRequired(boolean)} and is empty, if one or several of the * validators added to the field indicate it is invalid or if the value * cannot be converted provided a converter has been set. * * The "required" validation is a built-in validation feature. If the field * is required and empty this method throws an EmptyValueException with the * error message set using {@link #setRequiredError(String)}. * * @see Validatable#validate() */ @Override public void validate() throws Validator.InvalidValueException { if (isRequired() && isEmpty()) { throw new Validator.EmptyValueException(requiredError); } validate(getFieldValue()); }