All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.holonplatform.vaadin7.components.builders.ValidatableInputBuilder Maven / Gradle / Ivy

/*
 * Copyright 2000-2017 Holon TDCN.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.holonplatform.vaadin7.components.builders;

import com.holonplatform.core.Validator;
import com.holonplatform.core.i18n.Localizable;
import com.holonplatform.vaadin7.components.Input;
import com.holonplatform.vaadin7.components.ValidatableInput;
import com.holonplatform.vaadin7.components.ValidationStatusHandler;
import com.holonplatform.vaadin7.internal.components.ValidationUtils;

/**
 * {@link ValidatableInput} builder.
 * 
 * @param  Value type
 * @param  Concrete input type
 *
 * @since 5.0.0
 */
public interface ValidatableInputBuilder> {

	/**
	 * Adds a {@link Validator} to the {@link Input} bound to given property.
	 * @param validator Validator to add (not null)
	 * @return this
	 */
	ValidatableInputBuilder withValidator(Validator validator);

	/**
	 * Adds a {@link com.vaadin.data.Validator} to the {@link Input} bound to given property.
	 * @param validator Validator to add (not null)
	 * @return this
	 */
	default ValidatableInputBuilder withVaadinValidator(com.vaadin.data.Validator validator) {
		return withValidator(ValidationUtils.asValidator(validator));
	}

	/**
	 * Set the {@link ValidationStatusHandler} to use to input validation status changes.
	 * @param validationStatusHandler the {@link ValidationStatusHandler} to set (not null)
	 * @return this
	 */
	ValidatableInputBuilder validationStatusHandler(ValidationStatusHandler validationStatusHandler);

	/**
	 * Sets whether to validate the {@link Input} component value every time the {@link Input} value changes.
	 * 

* Default is true. *

* @param validateOnValueChange true to perform value validation every time the {@link Input} value * changes, false if not * @return this */ ValidatableInputBuilder validateOnValueChange(boolean validateOnValueChange); /** * Sets the {@link Input} as required. Required inputs must filled by the user, and its validation will fail when * empty. * @return this */ ValidatableInputBuilder required(); /** * Set the {@link Input} as required, using given {@link Validator} to check the input value. Required inputs must * filled by the user, and its validation will fail when empty. * @param validator The {@link Validator} to use to check the required input value (not null) * @return this */ ValidatableInputBuilder required(Validator validator); /** * Sets the {@link Input} as required, using given message as validation error message. Required inputs must filled * by the user, and its validation will fail when empty. * @param message The message to use to notify the required validation failure * @return this */ ValidatableInputBuilder required(Localizable message); /** * Sets the {@link Input} as required, using given message as validation error message. Required inputs must filled * by the user, and its validation will fail when empty. * @param message The default message to use to notify the required validation failure * @param messageCode The message localization code * @param arguments Optional message translation arguments * @return this */ default ValidatableInputBuilder required(String message, String messageCode, Object... arguments) { return required( Localizable.builder().message(message).messageCode(messageCode).messageArguments(arguments).build()); } /** * Sets the {@link Input} as required, using given message as validation error message. Required inputs must filled * by the user, and its validation will fail when empty. * @param message The default message to use to notify the required validation failure * @return this */ default ValidatableInputBuilder required(String message) { return required(Localizable.builder().message(message).build()); } /** * Build the {@link ValidatableInput} instance. * @return the {@link ValidatableInput} instance */ C build(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy