|
org.openide.util 7.9.0 1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openide.util.Parameters
public class Parameters
Utilities for checking the values of method parameters.
Methods in this class generally take the name of
the parameter to check and its value and throw exceptions
with messages according to the method name or just return. For example,
if you have a myMethod()
method taking a myParam
parameter whose value must be a Java identifier, you usually check that
by doing:
public void myMethod(String myParam) { if (!Utilities.isJavaIdentifier(myParam)) { throw new IllegalArgumentException("The myParam parameter is not a valid Java identifier"); } }Using this class you can do the same in a simpler way:
public void myMethod(String myParam) { Parameters.javaIdentifier("myParam", myParam); }
Method Summary | |
---|---|
static void |
javaIdentifier(CharSequence name,
CharSequence value)
Asserts the parameter value is not null and it is
a Java identifier. |
static void |
javaIdentifierOrNull(CharSequence name,
CharSequence value)
Asserts the parameter value is either null or a Java
identifier. |
static void |
notEmpty(CharSequence name,
CharSequence value)
Asserts the parameter value is neither null nor an empty
character sequence. |
static void |
notNull(CharSequence name,
Object value)
Asserts the parameter value is not null . |
static void |
notWhitespace(CharSequence name,
CharSequence value)
Asserts the parameter value is not null and it contains
at least one non-whitespace character. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void notNull(CharSequence name, Object value)
null
.
name
- the parameter name.value
- the parameter value.
NullPointerException
- if the parameter value is null
.public static void notEmpty(CharSequence name, CharSequence value)
null
nor an empty
character sequence.
name
- the parameter name.value
- the parameter value.
NullPointerException
- if the parameter value is null
.
IllegalArgumentException
- if the parameter value is an empty
character sequence.public static void notWhitespace(CharSequence name, CharSequence value)
null
and it contains
at least one non-whitespace character. Whitespace is defined as by
String.trim()
.
name
- the parameter name.value
- the parameter value.
NullPointerException
- if the parameter value is null
.
IllegalArgumentException
- if the parameter value does not
contain at least one non-whitespace character.public static void javaIdentifier(CharSequence name, CharSequence value)
null
and it is
a Java identifier.
name
- the parameter name.value
- the parameter value.
NullPointerException
- if the parameter value is null
.
IllegalArgumentException
- if the parameter value is not
a Java identifier.public static void javaIdentifierOrNull(CharSequence name, CharSequence value)
null
or a Java
identifier.
name
- the parameter name.value
- the parameter value.
IllegalArgumentException
- if the parameter value is neither
null
nor a Java identifier.
|
org.openide.util 7.9.0 1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |