diff options
author | denis.magdenkov <denis.magdenkov@arcadia.spb.ru> | 2014-09-06 15:58:25 +0400 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-09-17 10:10:16 +0000 |
commit | ca7dfd60d66bfdf32a15eccd6c7b5ae62baba39c (patch) | |
tree | 2007c096164c95a6b1566e1e5b68c97360104ebd /server/src/com/vaadin/data | |
parent | a8d2a80d467343a73857b28ea813090ecae11fdf (diff) | |
download | vaadin-framework-ca7dfd60d66bfdf32a15eccd6c7b5ae62baba39c.tar.gz vaadin-framework-ca7dfd60d66bfdf32a15eccd6c7b5ae62baba39c.zip |
Add Range<Byte, Short, Long, Float, BigInteger, BigDecimal> Validators (#14584)
Fix code review points.
Change-Id: Ia1ef55ff7ef806f9b71cb97f8f09bd4c6ec97a41
Diffstat (limited to 'server/src/com/vaadin/data')
6 files changed, 286 insertions, 0 deletions
diff --git a/server/src/com/vaadin/data/validator/BigDecimalRangeValidator.java b/server/src/com/vaadin/data/validator/BigDecimalRangeValidator.java new file mode 100644 index 0000000000..9b1d2bb565 --- /dev/null +++ b/server/src/com/vaadin/data/validator/BigDecimalRangeValidator.java @@ -0,0 +1,50 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * 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.vaadin.data.validator; + +import java.math.BigDecimal; + +/** + * Validator for validating that an {@link BigDecimal} is inside a given range. + * + * @author Vaadin Ltd. + * @since + */ +@SuppressWarnings("serial") +public class BigDecimalRangeValidator extends RangeValidator<BigDecimal> { + + /** + * Creates a validator for checking that an BigDecimal is within a given + * range. + * + * By default the range is inclusive i.e. both minValue and maxValue are + * valid values. Use {@link #setMinValueIncluded(boolean)} or + * {@link #setMaxValueIncluded(boolean)} to change it. + * + * + * @param errorMessage + * the message to display in case the value does not validate. + * @param minValue + * The minimum value to accept or null for no limit + * @param maxValue + * The maximum value to accept or null for no limit + */ + public BigDecimalRangeValidator(String errorMessage, BigDecimal minValue, + BigDecimal maxValue) { + super(errorMessage, BigDecimal.class, minValue, maxValue); + } + +} diff --git a/server/src/com/vaadin/data/validator/BigIntegerRangeValidator.java b/server/src/com/vaadin/data/validator/BigIntegerRangeValidator.java new file mode 100644 index 0000000000..bfe9dadc3f --- /dev/null +++ b/server/src/com/vaadin/data/validator/BigIntegerRangeValidator.java @@ -0,0 +1,50 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * 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.vaadin.data.validator; + +import java.math.BigInteger; + +/** + * Validator for validating that an {@link BigInteger} is inside a given range. + * + * @author Vaadin Ltd. + * @since + */ +@SuppressWarnings("serial") +public class BigIntegerRangeValidator extends RangeValidator<BigInteger> { + + /** + * Creates a validator for checking that an BigInteger is within a given + * range. + * + * By default the range is inclusive i.e. both minValue and maxValue are + * valid values. Use {@link #setMinValueIncluded(boolean)} or + * {@link #setMaxValueIncluded(boolean)} to change it. + * + * + * @param errorMessage + * the message to display in case the value does not validate. + * @param minValue + * The minimum value to accept or null for no limit + * @param maxValue + * The maximum value to accept or null for no limit + */ + public BigIntegerRangeValidator(String errorMessage, BigInteger minValue, + BigInteger maxValue) { + super(errorMessage, BigInteger.class, minValue, maxValue); + } + +} diff --git a/server/src/com/vaadin/data/validator/ByteRangeValidator.java b/server/src/com/vaadin/data/validator/ByteRangeValidator.java new file mode 100644 index 0000000000..c09a290d8a --- /dev/null +++ b/server/src/com/vaadin/data/validator/ByteRangeValidator.java @@ -0,0 +1,46 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * 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.vaadin.data.validator; + +/** + * Validator for validating that an {@link Byte} is inside a given range. + * + * @author Vaadin Ltd. + * @since + */ +@SuppressWarnings("serial") +public class ByteRangeValidator extends RangeValidator<Byte> { + + /** + * Creates a validator for checking that an Byte is within a given range. + * + * By default the range is inclusive i.e. both minValue and maxValue are + * valid values. Use {@link #setMinValueIncluded(boolean)} or + * {@link #setMaxValueIncluded(boolean)} to change it. + * + * + * @param errorMessage + * the message to display in case the value does not validate. + * @param minValue + * The minimum value to accept or null for no limit + * @param maxValue + * The maximum value to accept or null for no limit + */ + public ByteRangeValidator(String errorMessage, Byte minValue, Byte maxValue) { + super(errorMessage, Byte.class, minValue, maxValue); + } + +} diff --git a/server/src/com/vaadin/data/validator/FloatRangeValidator.java b/server/src/com/vaadin/data/validator/FloatRangeValidator.java new file mode 100644 index 0000000000..903c8c475f --- /dev/null +++ b/server/src/com/vaadin/data/validator/FloatRangeValidator.java @@ -0,0 +1,47 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * 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.vaadin.data.validator; + +/** + * Validator for validating that a {@link Float} is inside a given range. + * + * @author Vaadin Ltd. + * @since + */ +@SuppressWarnings("serial") +public class FloatRangeValidator extends RangeValidator<Float> { + + /** + * Creates a validator for checking that an Float is within a given range. + * + * By default the range is inclusive i.e. both minValue and maxValue are + * valid values. Use {@link #setMinValueIncluded(boolean)} or + * {@link #setMaxValueIncluded(boolean)} to change it. + * + * + * @param errorMessage + * the message to display in case the value does not validate. + * @param minValue + * The minimum value to accept or null for no limit + * @param maxValue + * The maximum value to accept or null for no limit + */ + public FloatRangeValidator(String errorMessage, Float minValue, + Float maxValue) { + super(errorMessage, Float.class, minValue, maxValue); + } + +} diff --git a/server/src/com/vaadin/data/validator/LongRangeValidator.java b/server/src/com/vaadin/data/validator/LongRangeValidator.java new file mode 100644 index 0000000000..829b37e37b --- /dev/null +++ b/server/src/com/vaadin/data/validator/LongRangeValidator.java @@ -0,0 +1,46 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * 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.vaadin.data.validator; + +/** + * Validator for validating that an {@link Long} is inside a given range. + * + * @author Vaadin Ltd. + * @since + */ +@SuppressWarnings("serial") +public class LongRangeValidator extends RangeValidator<Long> { + + /** + * Creates a validator for checking that an Long is within a given range. + * + * By default the range is inclusive i.e. both minValue and maxValue are + * valid values. Use {@link #setMinValueIncluded(boolean)} or + * {@link #setMaxValueIncluded(boolean)} to change it. + * + * + * @param errorMessage + * the message to display in case the value does not validate. + * @param minValue + * The minimum value to accept or null for no limit + * @param maxValue + * The maximum value to accept or null for no limit + */ + public LongRangeValidator(String errorMessage, Long minValue, Long maxValue) { + super(errorMessage, Long.class, minValue, maxValue); + } + +} diff --git a/server/src/com/vaadin/data/validator/ShortRangeValidator.java b/server/src/com/vaadin/data/validator/ShortRangeValidator.java new file mode 100644 index 0000000000..70e0b7c1e8 --- /dev/null +++ b/server/src/com/vaadin/data/validator/ShortRangeValidator.java @@ -0,0 +1,47 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * 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.vaadin.data.validator; + +/** + * Validator for validating that an {@link Short} is inside a given range. + * + * @author Vaadin Ltd. + * @since + */ +@SuppressWarnings("serial") +public class ShortRangeValidator extends RangeValidator<Short> { + + /** + * Creates a validator for checking that an Short is within a given range. + * + * By default the range is inclusive i.e. both minValue and maxValue are + * valid values. Use {@link #setMinValueIncluded(boolean)} or + * {@link #setMaxValueIncluded(boolean)} to change it. + * + * + * @param errorMessage + * the message to display in case the value does not validate. + * @param minValue + * The minimum value to accept or null for no limit + * @param maxValue + * The maximum value to accept or null for no limit + */ + public ShortRangeValidator(String errorMessage, Short minValue, + Short maxValue) { + super(errorMessage, Short.class, minValue, maxValue); + } + +} |