|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bristle.javalib.util.BooleanWrapper
public class BooleanWrapper
This class wraps a Boolean. It is useful to subclass when you want an object that is essentially a Boolean, but can be distinguished from other Boolean types. For example, when you write a method with multiple parameters that are all Booleans, but serve different purposes, and you want to be sure they were passed in the correct order on the method call, you can define each parameter to be a different subclass of this class. Note: This class would not be necessary if java.lang.Boolean was not declared as "final".
Usage:
- The typical scenario for using this class is:
- Declare subclasses of this class:
public static class IsFlat extends BooleanWrapper
{ public IsFlat(boolean blnValue) { super(blnValue); } }
public static class IsHard extends BooleanWrapper
{ public IsHard(boolean blnValue) { super(blnValue); } }
- Declare a method that takes the subclasses as parameters:
public void validate(Boolean blnValue, IsFlat blnFlat, IsHard blnHard);
- Call the method, with order of arguments enforced:
validate(blnValue, new IsFlat(true), new IsHard(false));
- See the source code of the inner Tester class for more examples.
Assumptions:
Effects:
- None.
Anticipated Changes:
Notes:
Implementation Notes:
Portability Issues:
Revision History:
$Log$
| Nested Class Summary | |
|---|---|
static class |
BooleanWrapper.Tester
Each class contains a Tester inner class with a main() for easier unit testing. |
| Constructor Summary | |
|---|---|
BooleanWrapper(boolean blnValue)
Constructor. |
|
BooleanWrapper(Boolean blnValue)
Constructor. |
|
| Method Summary | |
|---|---|
static String |
castToString(BooleanWrapper wrapper)
Return the BooleanWrapper cast to a String, or null if the specified BooleanWrapper is null. |
boolean |
getboolean()
Get the wrapped Boolean. |
Boolean |
getBoolean()
Get the wrapped Boolean. |
void |
setboolean(boolean blnNew)
Set the wrapped Boolean. |
void |
setBoolean(Boolean blnNew)
Set the wrapped Boolean. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public BooleanWrapper(boolean blnValue)
blnValue - Value of the Booleanpublic BooleanWrapper(Boolean blnValue)
blnValue - Value of the Boolean| Method Detail |
|---|
public void setBoolean(Boolean blnNew)
blnNew - The new Boolean.public Boolean getBoolean()
public void setboolean(boolean blnNew)
blnNew - The new Boolean.public boolean getboolean()
public static String castToString(BooleanWrapper wrapper)
wrapper - BooleanWrapper to cast to String.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||