public class Guardian extends Object
assert
XXX methods which can be used to internally check
the arguments passed to methods.
All functions have been implemented with extreme caution in order to provide a maximum performance.
Constructor and Description |
---|
Guardian() |
Modifier and Type | Method and Description |
---|---|
static void |
assertEquals(String exprText,
boolean exprValue,
boolean expectedValue)
Checks if the given values are equal.
|
static void |
assertEquals(String exprText,
long exprValue,
long expectedValue)
Checks if the given values are equal.
|
static void |
assertEquals(String exprText,
Object exprValue,
Object expectedValue)
Checks if the given objects are equal.
|
static void |
assertGreaterThan(String exprText,
long exprValue,
long limit)
Checks if the given value is greater than the given limit.
|
static void |
assertNotNull(String exprText,
Object exprValue)
Checks whether the given argument value is not
null . |
static void |
assertNotNullOrEmpty(String exprText,
byte[] exprValue) |
static void |
assertNotNullOrEmpty(String exprText,
char[] exprValue) |
static void |
assertNotNullOrEmpty(String exprText,
double[] exprValue) |
static void |
assertNotNullOrEmpty(String exprText,
float[] exprValue) |
static void |
assertNotNullOrEmpty(String exprText,
int[] exprValue) |
static void |
assertNotNullOrEmpty(String exprText,
Object[] exprValue) |
static void |
assertNotNullOrEmpty(String exprText,
short[] exprValue) |
static void |
assertNotNullOrEmpty(String exprText,
String exprValue)
Checks whether the given (parameter) value string is not
null and not empty. |
static void |
assertSame(String exprText,
Object exprValue,
Object expectedValue)
Checks if the given objects are the same instances.
|
static void |
assertTrue(String message,
boolean condition)
Checks whether the given argument value is
true . |
static void |
assertWithinRange(String exprText,
double exprValue,
double rangeMin,
double rangeMax)
Checks if the given value are in the given range.
|
static void |
assertWithinRange(String exprText,
long exprValue,
long rangeMin,
long rangeMax)
Checks if the given value are in the given range.
|
public static void assertTrue(String message, boolean condition)
true
. If not, an
IllegalArgumentException
is thrown with the given message text.
This utility method is used to check arguments passed into methods:
public void setOrigin(double[] point) { Guardian.assertTrue("point.length == 2 || point.length == 3", point.length == 2 || point.length == 3); ... }
message
- the message textcondition
- the condition which must be trueIllegalArgumentException
- if condition
is false
public static void assertNotNull(String exprText, Object exprValue)
null
. If not, an
IllegalArgumentException
is thrown with a standardized message text using the supplied parameter
name.
This utility method is used to check arguments passed into methods:
public void setBounds(Rectangle bounds) { Guardian.assertNotNull("bounds", bounds); _bounds = rect; }
exprText
- the test expression as textexprValue
- the test expression resultIllegalArgumentException
- if exprValue
is null
public static void assertNotNullOrEmpty(String exprText, String exprValue)
null
and not empty. If not, an
IllegalArgumentException
is thrown with a standardized message text using the supplied parameter
name.
This utility method is used to check arguments passed into methods:
public void setProductId(String productId) { Guardian.assertNotNullOrEmpty("productId", productId); _productId = productId; }
exprText
- the test expression as textexprValue
- the test expression resultIllegalArgumentException
- if exprValue
is null
or an empty stringpublic static void assertNotNullOrEmpty(String exprText, byte[] exprValue)
public static void assertNotNullOrEmpty(String exprText, char[] exprValue)
public static void assertNotNullOrEmpty(String exprText, short[] exprValue)
public static void assertNotNullOrEmpty(String exprText, int[] exprValue)
public static void assertNotNullOrEmpty(String exprText, float[] exprValue)
public static void assertNotNullOrEmpty(String exprText, double[] exprValue)
public static void assertGreaterThan(String exprText, long exprValue, long limit)
IllegalArgumentException
is
thrown with a standardized message text using the supplied argument name.
This utility method is used to check arguments passed into methods:
public void setWeight(long weight) { Guardian.assertGreaterThan("weight", weight, 0); _weight = weight; }
exprText
- the test expression as textexprValue
- the test expression resultlimit
- the lower limit for the expression resultIllegalArgumentException
- if the exprValue
is less than or equal to limit
public static void assertEquals(String exprText, boolean exprValue, boolean expectedValue)
IllegalArgumentException
is thrown with a
standardized message text using the supplied message.
This utility method is used to check arguments passed into methods:
public void writeDataAtRegion(int x, inty, int w, int h, byte[] data) { Guardian.assertEquals("data.length", data.length, w * h); ... }
exprText
- the test expression as textexprValue
- the test expression resultexpectedValue
- the expected valueIllegalArgumentException
- if the exprValue
is not equal to expectedValue
public static void assertEquals(String exprText, long exprValue, long expectedValue)
IllegalArgumentException
is thrown with a
standardized message text using the supplied message.
This utility method is used to check arguments passed into methods:
public void writeDataAtRegion(int x, inty, int w, int h, byte[] data) { Guardian.assertEquals("data.length", data.length, w * h); ... }
exprText
- the test expression as textexprValue
- the test expression resultexpectedValue
- the expected valueIllegalArgumentException
- if the exprValue
is not equal to expectedValue
public static void assertEquals(String exprText, Object exprValue, Object expectedValue)
IllegalArgumentException
is thrown with a
standardized message text using the supplied message.
This utility method is used to check arguments passed into methods:
public NewBandDialog(final Window parent, ProductNodeList products) { Guardian.assertNotNull("products", products); Guardian.assertEquals("not the expected element type", Product.class, products.getElemType()); ... }
exprText
- the test expression as textexprValue
- the test expression resultexpectedValue
- the expected valueIllegalArgumentException
- if the exprValue
is not equal to expectedValue
public static void assertSame(String exprText, Object exprValue, Object expectedValue)
IllegalArgumentException
is thrown
with a standardized message text using the supplied message.
This utility method is used to check arguments passed into methods:
public NewBandDialog(final Window parent, ProductNodeList products) { Guardian.assertNotNull("products", products); Guardian.assertEquals("not the expected element type", Product.class, products.getElemType()); ... }
exprText
- the test expression as textexprValue
- the actual valueexpectedValue
- the expected valueIllegalArgumentException
- if the expected
is not identical to actual
public static void assertWithinRange(String exprText, long exprValue, long rangeMin, long rangeMax)
IllegalArgumentException
is thrown with
a standardized message text using the supplied value name.
This utility method is used to check arguments passed into methods:
public void writeDataAtRegion(int x, inty, int w, int h, byte[] data) { Guardian.assertWithinRange("w", w, 0, data.length -1); ... }
exprText
- the test expression as textexprValue
- the expression resultrangeMin
- the range lower limitrangeMax
- the range upper limitIllegalArgumentException
- if the exprValue
is less than rangeMin
or greater than rangeMax
public static void assertWithinRange(String exprText, double exprValue, double rangeMin, double rangeMax)
IllegalArgumentException
is thrown with
a standardized message text using the supplied value name.
This utility method is used to check arguments passed into methods:
public void writeDataAtRegion(int x, inty, int w, int h, byte[] data) { Guardian.assertWithinRange("w", w, 0, data.length); ... }
exprText
- the test expression as textexprValue
- the expression resultrangeMin
- the range lower limitrangeMax
- the range upper limitIllegalArgumentException
- if the exprValue
is less than rangeMin
or greater than rangeMax
Copyright © 2014–2017 European Space Agency (ESA). All rights reserved.