@Documented @Target(value={FIELD,METHOD}) @Retention(value=RUNTIME) public @interface ValueRange
By default, both endpoints are inclusive. To make an endpoint exclusive, a@ValueRange(minimum=0, maximum=100) public double getCloudCoverPercentage() { // Method implementation here... }
isFooInclusive
argument needs to be explicitely provided. This
is useful mostly for floating point numbers. In the following example,
values can be very close to zero but not equals, since a value of exactly
zero makes no sense. Note also that the maximum
value is not explicitely
provided, in which case it defaults to infinity.
It is sometime convenient to convert@@ValueRange(minimum=0, isMinIncluded=false) public double getSpatialResolution() { // Method implementation here... }
ValueRange
to NumberRange
instances
in order to leverage the various NumberRange
operations. The following example
uses a convenience constructor for this purpose. Note that the Double
type could
by inferred from Method.getReturnType()
.
TheMethod myMethod = ...; ValueRange annotation = myMethod.getAnnotation(ValueRange.class); if (annotation != null) { NumberRange<Double> range = new NumberRange(Double.class, annotation); // Use the range here. }
AbstractMetadata
class uses this annotation for inferring
ParameterDescriptor
from metadata interfaces and implementation
classes.NumberRange.NumberRange(Class, ValueRange)
Defined in the sis-utility module
Modifier and Type | Optional Element and Description |
---|---|
boolean |
isMaxIncluded
|
boolean |
isMinIncluded
|
double |
maximum
Returns the maximal value that a method can return.
|
double |
minimum
Returns the minimal value that a method can return.
|
public abstract double minimum
public abstract boolean isMinIncluded
true
if the minimal value is inclusive, or false
if it is exclusive. By default the minimum value is inclusive.true
if the minimum value is inclusive.public abstract double maximum
public abstract boolean isMaxIncluded
true
if the maximal value is inclusive, or false
if it is exclusive. By default the maximum value is inclusive.true
if the maximum value is inclusive.Copyright © 2010–2013 The Apache Software Foundation. All rights reserved.