Package com.linkare.commons.utils
Class BooleanResult
- java.lang.Object
-
- com.linkare.commons.utils.BooleanResult
-
- All Implemented Interfaces:
Serializable
public final class BooleanResult extends Object implements Serializable
Utility class to store a boolean result and a message to explain the reason why the result is either true, false or undetermined (null). The message may be used, for instance, as a resource bundle key in which clients use it to supply details about any operations performed.- Author:
- Paulo Zenida - Linkare TI
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static BooleanResultFALSE_RESULTUtility constant to represent the false result without any detail messageprivate static intHASH_CODE_INITprivate static intHASH_CODE_MULTIPLIERprivate StringmessageThe details message associated to this boolean result type.private BooleanresultThe result of the boolean result type is immutable.private static longserialVersionUIDstatic BooleanResultTRUE_RESULTUtility constant to represent the true result without any detail messagestatic BooleanResultUNDETERMINED_RESULTUtility constant to represent the undetermined result without any detail message
-
Constructor Summary
Constructors Modifier Constructor Description privateBooleanResult(Boolean result)This constructor is private to "force" the client code from this class to use the constants.BooleanResult(Boolean result, String message)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object other)private booleanequalsTo(BooleanResult other)StringgetMessage()BooleangetResult()inthashCode()BooleanResultsetMessage(String message)StringtoString()
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
HASH_CODE_MULTIPLIER
private static final int HASH_CODE_MULTIPLIER
- See Also:
- Constant Field Values
-
HASH_CODE_INIT
private static final int HASH_CODE_INIT
- See Also:
- Constant Field Values
-
result
private final Boolean result
The result of the boolean result type is immutable. Once created, it should not be possible to change it. This means a true result, for instance, will always be a true result.
-
message
private String message
The details message associated to this boolean result type. It should not be final to enable the possibility for this type's clients to add a details message associated to the result of the evaluation in which this type was used.
-
TRUE_RESULT
public static final BooleanResult TRUE_RESULT
Utility constant to represent the true result without any detail message
-
FALSE_RESULT
public static final BooleanResult FALSE_RESULT
Utility constant to represent the false result without any detail message
-
UNDETERMINED_RESULT
public static final BooleanResult UNDETERMINED_RESULT
Utility constant to represent the undetermined result without any detail message
-
-
Constructor Detail
-
BooleanResult
private BooleanResult(Boolean result)
This constructor is private to "force" the client code from this class to use the constants.- Parameters:
result- the result to set.
-
-
Method Detail
-
getResult
public Boolean getResult()
- Returns:
- the result
-
getMessage
public String getMessage()
- Returns:
- the message
-
setMessage
public BooleanResult setMessage(String message)
- Parameters:
message- the message to set
-
equalsTo
private boolean equalsTo(BooleanResult other)
-
-