io.guise.framework.validator.AbstractRangeValidator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of guise-framework Show documentation
Show all versions of guise-framework Show documentation
Guise™ Internet application framework.
/*
* Copyright © 2005-2008 GlobalMentor, Inc.
*
* 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 io.guise.framework.validator;
/**
* An abstract implementation of a validator restricted to a range. The step value is considered relative either to the minimum value, if available, the maximum
* value, if available, or zero, in that order or priority.
* @param The value type this validator supports.
* @author Garret Wilson
*/
public abstract class AbstractRangeValidator extends AbstractValidator implements RangeValidator {
/** The minimum value, inclusive, or null
if the range has no lower bound. */
private final V minimum;
@Override
public V getMinimum() {
return minimum;
}
/** The maximum value, inclusive, or null
if the range has no upper bound. */
private final V maximum;
@Override
public V getMaximum() {
return maximum;
}
/** The step amount, or null
if the range has no increment value specified. */
private final V step;
@Override
public V getStep() {
return step;
}
/**
* Minimum, maximum, step, and value required constructor.
* @param minimum The minimum value, inclusive, or null
if the range has no lower bound.
* @param maximum The maximum value, inclusive, or null
if the range has no upper bound.
* @param step The step amount, or null
if the range has no increment value specified.
* @param valueRequired Whether the value must be non-null
in order to be considered valid.
*/
public AbstractRangeValidator(final V minimum, final V maximum, final V step, final boolean valueRequired) {
super(valueRequired); //construct the parent class
this.minimum = minimum;
this.maximum = maximum;
this.step = step;
}
}