public class FieldUtils
extends java.lang.Object
FieldUtils is thread-safe and immutable.
Modifier and Type | Method and Description |
---|---|
static boolean |
equals(java.lang.Object object1,
java.lang.Object object2)
Compares two objects as equals handling null.
|
static int |
getWrappedValue(int value,
int minValue,
int maxValue)
Utility method that ensures the given value lies within the field's
legal value range.
|
static int |
getWrappedValue(int currentValue,
int wrapValue,
int minValue,
int maxValue)
Utility method used by addWrapField implementations to ensure the new
value lies within the field's legal value range.
|
static int |
safeAdd(int val1,
int val2)
Add two values throwing an exception if overflow occurs.
|
static long |
safeAdd(long val1,
long val2)
Add two values throwing an exception if overflow occurs.
|
static long |
safeDivide(long dividend,
long divisor)
Divides the dividend by the divisor throwing an exception if
overflow occurs or the divisor is zero.
|
static int |
safeMultiply(int val1,
int val2)
Multiply two values throwing an exception if overflow occurs.
|
static long |
safeMultiply(long val1,
int val2)
Multiply two values throwing an exception if overflow occurs.
|
static long |
safeMultiply(long val1,
long val2)
Multiply two values throwing an exception if overflow occurs.
|
static int |
safeMultiplyToInt(long val1,
long val2)
Multiply two values to return an int throwing an exception if overflow occurs.
|
static int |
safeNegate(int value)
Negates the input throwing an exception if it can't negate it.
|
static long |
safeSubtract(long val1,
long val2)
Subtracts two values throwing an exception if overflow occurs.
|
static int |
safeToInt(long value)
Casts to an int throwing an exception if overflow occurs.
|
static void |
verifyValueBounds(DateTimeField field,
int value,
int lowerBound,
int upperBound)
Verify that input values are within specified bounds.
|
static void |
verifyValueBounds(DateTimeFieldType fieldType,
int value,
int lowerBound,
int upperBound)
Verify that input values are within specified bounds.
|
static void |
verifyValueBounds(java.lang.String fieldName,
int value,
int lowerBound,
int upperBound)
Verify that input values are within specified bounds.
|
public static int safeNegate(int value)
value
- the value to negatejava.lang.ArithmeticException
- if the value is Integer.MIN_VALUEpublic static int safeAdd(int val1, int val2)
val1
- the first valueval2
- the second valuejava.lang.ArithmeticException
- if the value is too big or too smallpublic static long safeAdd(long val1, long val2)
val1
- the first valueval2
- the second valuejava.lang.ArithmeticException
- if the value is too big or too smallpublic static long safeSubtract(long val1, long val2)
val1
- the first value, to be taken away fromval2
- the second value, the amount to take awayjava.lang.ArithmeticException
- if the value is too big or too smallpublic static int safeMultiply(int val1, int val2)
val1
- the first valueval2
- the second valuejava.lang.ArithmeticException
- if the value is too big or too smallpublic static long safeMultiply(long val1, int val2)
val1
- the first valueval2
- the second valuejava.lang.ArithmeticException
- if the value is too big or too smallpublic static long safeMultiply(long val1, long val2)
val1
- the first valueval2
- the second valuejava.lang.ArithmeticException
- if the value is too big or too smallpublic static long safeDivide(long dividend, long divisor)
dividend
- the dividenddivisor
- the divisorjava.lang.ArithmeticException
- if the operation overflows or the divisor is zeropublic static int safeToInt(long value)
value
- the valuejava.lang.ArithmeticException
- if the value is too big or too smallpublic static int safeMultiplyToInt(long val1, long val2)
val1
- the first valueval2
- the second valuejava.lang.ArithmeticException
- if the value is too big or too smallpublic static void verifyValueBounds(DateTimeField field, int value, int lowerBound, int upperBound)
value
- the value to checklowerBound
- the lower bound allowed for valueupperBound
- the upper bound allowed for valueIllegalFieldValueException
- if value is not in the specified boundspublic static void verifyValueBounds(DateTimeFieldType fieldType, int value, int lowerBound, int upperBound)
value
- the value to checklowerBound
- the lower bound allowed for valueupperBound
- the upper bound allowed for valueIllegalFieldValueException
- if value is not in the specified boundspublic static void verifyValueBounds(java.lang.String fieldName, int value, int lowerBound, int upperBound)
value
- the value to checklowerBound
- the lower bound allowed for valueupperBound
- the upper bound allowed for valueIllegalFieldValueException
- if value is not in the specified boundspublic static int getWrappedValue(int currentValue, int wrapValue, int minValue, int maxValue)
currentValue
- the current value of the data, which may lie outside
the wrapped value rangewrapValue
- the value to add to current value before
wrapping. This may be negative.minValue
- the wrap range minimum value.maxValue
- the wrap range maximum value. This must be
greater than minValue (checked by the method).java.lang.IllegalArgumentException
- if minValue is greater
than or equal to maxValuepublic static int getWrappedValue(int value, int minValue, int maxValue)
value
- the value to fit into the wrapped value rangeminValue
- the wrap range minimum value.maxValue
- the wrap range maximum value. This must be
greater than minValue (checked by the method).java.lang.IllegalArgumentException
- if minValue is greater
than or equal to maxValuepublic static boolean equals(java.lang.Object object1, java.lang.Object object2)
object1
- the first objectobject2
- the second objectCopyright © 2010 - 2020 Adobe. All Rights Reserved