|
StocksMonitor 1.5.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
ObjectArgs
public final class Args
Utility methods for common argument validations.
Replace if statements at the start of a method with more compact method calls.
| Constructor Summary | |
|---|---|
Args()
|
|
| Method Summary | |
|---|---|
static void |
checkForContent(String aText)
Throw an IllegalArgumentException if aText does not satisfy Util.textHasContent(java.lang.String). |
static void |
checkForEmpty(Collection aCollection)
Throw an IllegalArgumentException only if aCollection.isEmpty returns true. |
static void |
checkForNull(Object aObject)
If aObject is null, throw a NullPointerException. |
static void |
checkForRange(int aNumber,
int aLow,
int aHigh)
Throw an IllegalArgumentException if Util.isInRange(int, int, int)
returns false. |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Args()
| Method Detail |
|---|
public static void checkForNull(Object aObject)
Use cases :
doSomething( SoccerBall aBall ){
//call some method on the argument :
//if aBall is null, then exception is automatically thrown, so
//there is no need for an explicit check for null.
aBall.inflate();
//assign to a corresponding field (common in constructors):
//if aBall is null, no exception is immediately thrown, so
//an explicit check for null may be useful here
Args.checkForNull( aBall );
fBall = aBall;
//passed on to some other method as param :
//it may or may not be appropriate to have an explicit check
//for null here, according the needs of the problem
Args.checkForNull( aBall ); //??
fReferee.verify( aBall );
}
public static void checkForContent(String aText)
Util.textHasContent(java.lang.String).
Most text used in an application is meaningful only if it has visible content.
public static void checkForRange(int aNumber,
int aLow,
int aHigh)
Util.isInRange(int, int, int)
returns false.
aLow - is less than or equal to aHigh.public static void checkForEmpty(Collection aCollection)
|
StocksMonitor 1.5.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||