T
- The type of the contained object.public class ConvertedObject<T> extends Object
Modifier | Constructor and Description |
---|---|
protected |
ConvertedObject(boolean notConvertible,
T object) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
canEqual(Object other) |
boolean |
equals(Object o) |
T |
get()
Retrieves the converted object.
|
T |
getObject() |
int |
hashCode() |
boolean |
isConvertible()
Checks whether the conversion succeeded and the value could be converted.
|
boolean |
isNotConvertible()
Checks whether the conversion failed and the value could not be converted.
|
static <T> ConvertedObject<T> |
of(T convertedObject)
Creates a
ConvertedObject containing the given object as its value. |
static <T> ConvertedObject<T> |
ofNotConvertible()
Creates a
ConvertedObject containing null as its value. |
static <T> ConvertedObject<T> |
ofNull()
Creates a
ConvertedObject containing null as its value. |
T |
orElse(T defaultValue)
Returns the contained value, or the given default value if the object was not convertible.
|
T |
orNull()
Returns the contained value, or
null if the object was not convertible. |
String |
toString() |
@Nullable public T get() throws ObjectNotConvertibleException
null
.ObjectNotConvertibleException
- If the object is not convertible.@Nullable public T orNull()
null
if the object was not convertible.null
if the object was not convertible.@Nullable public T orElse(@Nullable T defaultValue)
defaultValue
- The value to return in case this ConvertedObject
was not convertible.public boolean isConvertible()
true
if the value could be converted, false
else.@Nonnull public static <T> ConvertedObject<T> of(@Nullable T convertedObject)
ConvertedObject
containing the given object as its value.T
- The type of the object to wrap.convertedObject
- The object to wrap in a ConvertedObject
.ConvertedObject
wrapping convertedObject
.@Nonnull public static <T> ConvertedObject<T> ofNull()
ConvertedObject
containing null
as its value. The reason to use this method might be
that no object was given to convert.T
- The type the contained value should have.ConvertedObject
containing only null
.@Nonnull public static <T> ConvertedObject<T> ofNotConvertible()
ConvertedObject
containing null
as its value. The reason to use this method might be
that the given object could not be converted.T
- The type the contained value should have.ConvertedObject
containing only null
.protected boolean canEqual(Object other)
public boolean isNotConvertible()
true
if the value could not be converted, false
else.Copyright © 2018 SAP SE. All rights reserved.