Package com.sap.cloud.sdk.result
Class GsonResultPrimitive
java.lang.Object
com.sap.cloud.sdk.result.GsonResultPrimitive
- All Implemented Interfaces:
ResultElement
,ResultPrimitive
ResultPrimitive
implementation based on a JsonPrimitive
.-
Field Summary
Modifier and TypeFieldDescriptionprotected final com.google.gson.JsonPrimitive
The underlyingJsonPrimitive
instance. -
Constructor Summary
ConstructorDescriptionGsonResultPrimitive
(com.google.gson.JsonPrimitive jsonPrimitive) Creates a newGsonResultPrimitive
instance. -
Method Summary
Modifier and TypeMethodDescriptionIn case thisResultElement
is considered aResultPrimitive
, use this method to access its value asBigDecimal
.In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asBigInteger
.boolean
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asboolean
.byte
asByte()
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asbyte
.char
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value aschar
.double
asDouble()
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asdouble
.float
asFloat()
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asfloat
.int
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asint
.long
asLong()
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value aslong
.short
asShort()
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asshort
.asString()
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asString
.protected boolean
boolean
Returns thisResultElement
as an instance ofResultCollection
.Returns thisResultElement
as an instance ofResultObject
.Returns thisResultElement
as an instance ofResultPrimitive
.com.google.gson.JsonPrimitive
The underlyingJsonPrimitive
instance.int
hashCode()
boolean
Checks whether thisResultElement
represents a collection of result elements and, therefore, is aResultCollection
.boolean
Checks whether thisResultElement
represents a structured object and, therefore, is aResultObject
.boolean
Checks whether thisResultElement
represents an unstructured value and, therefore, is aResultPrimitive
.toString()
-
Field Details
-
jsonPrimitive
protected final com.google.gson.JsonPrimitive jsonPrimitiveThe underlyingJsonPrimitive
instance.
-
-
Constructor Details
-
GsonResultPrimitive
public GsonResultPrimitive(com.google.gson.JsonPrimitive jsonPrimitive) Creates a newGsonResultPrimitive
instance.- Parameters:
jsonPrimitive
- The underlyingJsonPrimitive
instance.
-
-
Method Details
-
isResultPrimitive
public boolean isResultPrimitive()Description copied from interface:ResultElement
Checks whether thisResultElement
represents an unstructured value and, therefore, is aResultPrimitive
.- Specified by:
isResultPrimitive
in interfaceResultElement
- Returns:
- True of this object is a
ResultPrimitive
, otherwise false.
-
isResultCollection
public boolean isResultCollection()Description copied from interface:ResultElement
Checks whether thisResultElement
represents a collection of result elements and, therefore, is aResultCollection
.- Specified by:
isResultCollection
in interfaceResultElement
- Returns:
- True of this object is a
ResultCollection
, otherwise false.
-
isResultObject
public boolean isResultObject()Description copied from interface:ResultElement
Checks whether thisResultElement
represents a structured object and, therefore, is aResultObject
.- Specified by:
isResultObject
in interfaceResultElement
- Returns:
- True of this object is a
ResultObject
, otherwise false.
-
getAsPrimitive
Description copied from interface:ResultElement
Returns thisResultElement
as an instance ofResultPrimitive
.- Specified by:
getAsPrimitive
in interfaceResultElement
- Returns:
- An instance of
ResultPrimitive
.
-
getAsCollection
Description copied from interface:ResultElement
Returns thisResultElement
as an instance ofResultCollection
.- Specified by:
getAsCollection
in interfaceResultElement
- Returns:
- An instance of
ResultCollection
. - Throws:
UnsupportedOperationException
- If the cast intoResultCollection
failed, e.g. in case it is not a collection.
-
getAsObject
Description copied from interface:ResultElement
Returns thisResultElement
as an instance ofResultObject
.- Specified by:
getAsObject
in interfaceResultElement
- Returns:
- An instance of
ResultObject
. - Throws:
UnsupportedOperationException
- If the cast intoResultObject
failed, e.g. in case it is not an object.
-
asBoolean
Description copied from interface:ResultElement
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asboolean
.- Specified by:
asBoolean
in interfaceResultElement
- Specified by:
asBoolean
in interfaceResultPrimitive
- Returns:
boolean
value.- Throws:
UnsupportedOperationException
- If thisResultElement
is not considered aResultPrimitive
or its value cannot be represented asboolean
.
-
asByte
Description copied from interface:ResultElement
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asbyte
.- Specified by:
asByte
in interfaceResultElement
- Specified by:
asByte
in interfaceResultPrimitive
- Returns:
byte
value.- Throws:
UnsupportedOperationException
- If thisResultElement
is not considered aResultPrimitive
or its value cannot be represented asbyte
.
-
asCharacter
Description copied from interface:ResultElement
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value aschar
.- Specified by:
asCharacter
in interfaceResultElement
- Specified by:
asCharacter
in interfaceResultPrimitive
- Returns:
char
value.- Throws:
UnsupportedOperationException
- If thisResultElement
is not considered aResultPrimitive
or its value cannot be represented aschar
.
-
asString
Description copied from interface:ResultElement
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asString
.- Specified by:
asString
in interfaceResultElement
- Specified by:
asString
in interfaceResultPrimitive
- Returns:
String
object.- Throws:
UnsupportedOperationException
- If thisResultElement
is not considered aResultPrimitive
or its value cannot be represented asString
.
-
asInteger
Description copied from interface:ResultElement
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asint
.- Specified by:
asInteger
in interfaceResultElement
- Specified by:
asInteger
in interfaceResultPrimitive
- Returns:
int
value.- Throws:
UnsupportedOperationException
- If thisResultElement
is not considered aResultPrimitive
or its value cannot be represented asint
.
-
asShort
Description copied from interface:ResultElement
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asshort
.- Specified by:
asShort
in interfaceResultElement
- Specified by:
asShort
in interfaceResultPrimitive
- Returns:
short
value.- Throws:
UnsupportedOperationException
- If thisResultElement
is not considered aResultPrimitive
or its value cannot be represented asshort
.
-
asLong
Description copied from interface:ResultElement
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value aslong
.- Specified by:
asLong
in interfaceResultElement
- Specified by:
asLong
in interfaceResultPrimitive
- Returns:
long
value.- Throws:
UnsupportedOperationException
- If thisResultElement
is not considered aResultPrimitive
or its value cannot be represented aslong
.
-
asFloat
Description copied from interface:ResultElement
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asfloat
.- Specified by:
asFloat
in interfaceResultElement
- Specified by:
asFloat
in interfaceResultPrimitive
- Returns:
float
value.- Throws:
UnsupportedOperationException
- If thisResultElement
is not considered aResultPrimitive
or its value cannot be represented asfloat
.
-
asDouble
Description copied from interface:ResultElement
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asdouble
.- Specified by:
asDouble
in interfaceResultElement
- Specified by:
asDouble
in interfaceResultPrimitive
- Returns:
double
value.- Throws:
UnsupportedOperationException
- If thisResultElement
is not considered aResultPrimitive
or its value cannot be represented asdouble
.
-
asBigInteger
Description copied from interface:ResultElement
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asBigInteger
.- Specified by:
asBigInteger
in interfaceResultElement
- Specified by:
asBigInteger
in interfaceResultPrimitive
- Returns:
BigInteger
object.- Throws:
UnsupportedOperationException
- If thisResultElement
is not considered aResultPrimitive
or its value cannot be represented asBigInteger
.
-
asBigDecimal
Description copied from interface:ResultElement
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asBigDecimal
.- Specified by:
asBigDecimal
in interfaceResultElement
- Specified by:
asBigDecimal
in interfaceResultPrimitive
- Returns:
BigDecimal
object.- Throws:
UnsupportedOperationException
- If thisResultElement
is not considered aResultPrimitive
or its value cannot be represented asBigDecimal
.
-
getJsonPrimitive
public com.google.gson.JsonPrimitive getJsonPrimitive()The underlyingJsonPrimitive
instance. -
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-