注釈型 RequireRangeFromTo
@Documented @Target(FIELD) @Retention(RUNTIME) public @interface RequireRangeFromTo
An annotation that indicate that the numbers are within the lower and upper
limits.
Specify this annotation for fields that do not allow exceed the lower and upper limits,as follows. If this annotation is specified for an object of type other than int, long, short, byte, float, double, Integer, Long, Short, Byte, Float or Double, UnsupportedOperationException will always be thrown at runtime.
Specify the expected value for Content Framework:
@ParameterMapping( content = "Parameter" )
public class ConcreteEntity implements ValidatableEntity, Serializable {
@RequireRangeFromTo
private int intFromTo;
@RequireRangeFromTo( ErrorType.RECOVERABLE, message = "failed!" )
private long longFromTo;
@RequireRangeFromTo( ErrorType.UNRECOVERABLE, message = "failed!" )
private double doubleFromTo;
}
Specify the expected value for the annotation:
public class ConcreteEntity implements ValidatableEntity, Serializable {
@RequireRangeFromTo( intFrom = -10, intTo = 10 )
private int intFromTo;
@RequireRangeFromTo( longFrom = -10l, longTo = 10l, ErrorType.RECOVERABLE, message = "failed!" )
private long longFromTo;
@RequireRangeFromTo( doubleFrom = -10.0d, doubleTo = 10.0d, ErrorType.UNRECOVERABLE, message = "failed!" )
private double doubleFromTo;
}
- 導入されたバージョン:
- 1.0.0
-
任意要素の概要
任意要素 修飾子とタイプ 任意要素 説明 byte
byteFrom
Returns the lower limit of byte type.byte
byteTo
Returns the upper limit of byte type.double
doubleFrom
Returns the lower limit of double type.double
doubleTo
Returns the upper limit of double type.ErrorType
errorType
Returns the error type based onErrorType
, andErrorType.RUNTIME
is set as the default.float
floatFrom
Returns the lower limit of float type.float
floatTo
Returns the upper limit of float type.int
intFrom
Returns the lower limit of int type.int
intTo
Returns the upper limit of int type.long
longFrom
Returns the lower limit of long type.long
longTo
Returns the upper limit of long type.String
message
Returns the error type based onErrorType
, and empty (""
) is set as the default.short
shortFrom
Returns the lower limit of short type.short
shortTo
Returns the upper limit of short type.
-
要素の詳細
-
errorType
ErrorType errorTypeReturns the error type based onErrorType
, andErrorType.RUNTIME
is set as the default.- 戻り値:
- The error type based on the
ErrorType
- デフォルト:
- RUNTIME
-
message
String messageReturns the error type based onErrorType
, and empty (""
) is set as the default.- 戻り値:
- The message
- デフォルト:
- ""
-
intFrom
int intFromReturns the lower limit of int type. The default value isInteger.MIN_VALUE
.- 戻り値:
- The lower limit of int type
- 導入されたバージョン:
- 1.0.2
- デフォルト:
- -2147483648
-
longFrom
long longFromReturns the lower limit of long type. The default value isLong.MIN_VALUE
.- 戻り値:
- The lower limit of long type
- 導入されたバージョン:
- 1.0.2
- デフォルト:
- -9223372036854775808L
-
floatFrom
float floatFromReturns the lower limit of float type. The default value isFloat.MIN_VALUE
.- 戻り値:
- The lower limit of float type
- 導入されたバージョン:
- 1.0.2
- デフォルト:
- 1.4E-45f
-
doubleFrom
double doubleFromReturns the lower limit of double type. The default value isDouble.MIN_VALUE
.- 戻り値:
- The lower limit of double type
- 導入されたバージョン:
- 1.0.2
- デフォルト:
- 4.9E-324
-
shortFrom
short shortFromReturns the lower limit of short type. The default value isShort.MIN_VALUE
.- 戻り値:
- The lower limit of short type
- 導入されたバージョン:
- 1.0.2
- デフォルト:
- -32768
-
byteFrom
byte byteFromReturns the lower limit of byte type. The default value isByte.MIN_VALUE
.- 戻り値:
- The lower limit of byte type
- 導入されたバージョン:
- 1.0.2
- デフォルト:
- (byte)0x80
-
intTo
int intToReturns the upper limit of int type. The default value isInteger.MAX_VALUE
.- 戻り値:
- The upper limit of int type
- 導入されたバージョン:
- 1.0.2
- デフォルト:
- 2147483647
-
longTo
long longToReturns the upper limit of long type. The default value isLong.MAX_VALUE
.- 戻り値:
- The upper limit of long type
- 導入されたバージョン:
- 1.0.2
- デフォルト:
- 9223372036854775807L
-
floatTo
float floatToReturns the upper limit of float type. The default value isFloat.MAX_VALUE
.- 戻り値:
- The upper limit of float type
- 導入されたバージョン:
- 1.0.2
- デフォルト:
- 3.4028235E38f
-
doubleTo
double doubleToReturns the upper limit of double type. The default value isDouble.MAX_VALUE
.- 戻り値:
- The upper limit of double type
- 導入されたバージョン:
- 1.0.2
- デフォルト:
- 1.7976931348623157E308
-
shortTo
short shortToReturns the upper limit of short type. The default value isShort.MAX_VALUE
.- 戻り値:
- The upper limit of short type
- 導入されたバージョン:
- 1.0.2
- デフォルト:
- 32767
-
byteTo
byte byteToReturns the upper limit of byte type. The default value isByte.MAX_VALUE
.- 戻り値:
- The upper limit of byte type
- 導入されたバージョン:
- 1.0.2
- デフォルト:
- (byte)0x7f
-