#include <coherence/util/Objects.hpp>
Inherits Object.
Public Types | |
| typedef spec::Handle | Handle |
| Objects Handle definition. | |
| typedef spec::View | View |
| Objects View definition. | |
| typedef spec::Holder | Holder |
| Objects Holder definition. | |
Static Public Member Functions | |
| static String::View | toString (Object::View v, String::View vsNullDefault) |
| Returns the result of calling toString on the first argument if the first argument is not NULL and returns the second argument otherwise. | |
| static int32_t | compare (Object::View vA, Object::View vB, Comparator::View vC) |
| Returns 0 if the arguments are identical and vC->compare(vA, vB) otherwise. | |
| static Object::Holder | requireNonNull (Object::Holder oh) |
| Checks that the specified object reference is not NULL. | |
| static Object::Holder | requireNonNull (Object::Holder oh, String::View vsMessage) |
| Checks that the specified Object reference is not NULL and throws a customized NullPointerException if it is. | |
| static bool | isNull (Object::View v) |
| Returns true if the provided reference is NULL otherwise returns false. | |
| static bool | nonNull (Object::View v) |
| Returns true if the provided reference is non-NULL otherwise returns false. | |
| static String::View toString | ( | Object::View | v, | |
| String::View | vsNullDefault | |||
| ) | [static] |
Returns the result of calling toString on the first argument if the first argument is not NULL and returns the second argument otherwise.
| v | an Object | |
| vsNullDefault | string to return if the first argument is NULL |
| static int32_t compare | ( | Object::View | vA, | |
| Object::View | vB, | |||
| Comparator::View | vC | |||
| ) | [static] |
Returns 0 if the arguments are identical and vC->compare(vA, vB) otherwise.
Consequently, if both arguments are NULL, 0 is returned.
Note that if one of the arguments is NULL, a NullPointerException may or may not be thrown depending on what ordering policy, if any, the Comparator chooses to have for NULL values.
| vA | an Object | |
| vB | an Object to be compared with vA | |
| vC | the Comparator to compare the first two arguments |
| static Object::Holder requireNonNull | ( | Object::Holder | oh | ) | [static] |
Checks that the specified object reference is not NULL.
This method is designed primarily for doing parameter validation in methods and constructors, as demonstrated below: <blockquote>
protected Foo(Bar::View vBar) {
this.vBar = Objects::requireNonNull(vBar);
}
</blockquote>
| oh | the Object reference to check for nullity |
| NullPointerException | if oh is NULL |
| static Object::Holder requireNonNull | ( | Object::Holder | oh, | |
| String::View | vsMessage | |||
| ) | [static] |
Checks that the specified Object reference is not NULL and throws a customized NullPointerException if it is.
This method is designed primarily for doing parameter validation in methods and constructors with multiple parameters, as demonstrated below: <blockquote>
protected Foo(Bar::View vBar, Baz::View vBaz) {
this.vBar = Objects::requireNonNull(vBar, "vBar must not be null");
this.vBaz = Objects::requireNonNull(vBaz, "vBaz must not be null");
}
</blockquote>
| oh | the Object reference to check for nullity | |
| vsMessage | detail message to be used in the event that a NullPointerException is thrown |
| NullPointerException | if oh is NULL |
| static bool isNull | ( | Object::View | v | ) | [static] |
Returns true if the provided reference is NULL otherwise returns false.
| v | an Object to be checked against NULL |
| static bool nonNull | ( | Object::View | v | ) | [static] |
Returns true if the provided reference is non-NULL otherwise returns false.
| v | an Object to be checked against NULL |