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
FieldsModifier and TypeFieldDescriptionprotected final com.google.gson.JsonPrimitiveThe underlyingJsonPrimitiveinstance. -
Constructor Summary
ConstructorsConstructorDescriptionGsonResultPrimitive(com.google.gson.JsonPrimitive jsonPrimitive) Creates a newGsonResultPrimitiveinstance. -
Method Summary
Modifier and TypeMethodDescriptionIn case thisResultElementis considered aResultPrimitive, use this method to access its value asBigDecimal.In case thisResultElementis considered aResultPrimitive, use this method to access its value asBigInteger.booleanIn case thisResultElementis considered aResultPrimitive, use this method to access its value asboolean.byteasByte()In case thisResultElementis considered aResultPrimitive, use this method to access its value asbyte.charIn case thisResultElementis considered aResultPrimitive, use this method to access its value aschar.doubleasDouble()In case thisResultElementis considered aResultPrimitive, use this method to access its value asdouble.floatasFloat()In case thisResultElementis considered aResultPrimitive, use this method to access its value asfloat.intIn case thisResultElementis considered aResultPrimitive, use this method to access its value asint.longasLong()In case thisResultElementis considered aResultPrimitive, use this method to access its value aslong.shortasShort()In case thisResultElementis considered aResultPrimitive, use this method to access its value asshort.asString()In case thisResultElementis considered aResultPrimitive, use this method to access its value asString.protected booleanbooleanReturns thisResultElementas an instance ofResultCollection.Returns thisResultElementas an instance ofResultObject.Returns thisResultElementas an instance ofResultPrimitive.com.google.gson.JsonPrimitiveThe underlyingJsonPrimitiveinstance.inthashCode()booleanChecks whether thisResultElementrepresents a collection of result elements and, therefore, is aResultCollection.booleanChecks whether thisResultElementrepresents a structured object and, therefore, is aResultObject.booleanChecks whether thisResultElementrepresents an unstructured value and, therefore, is aResultPrimitive.toString()
-
Field Details
-
jsonPrimitive
protected final com.google.gson.JsonPrimitive jsonPrimitiveThe underlyingJsonPrimitiveinstance.
-
-
Constructor Details
-
GsonResultPrimitive
public GsonResultPrimitive(com.google.gson.JsonPrimitive jsonPrimitive) Creates a newGsonResultPrimitiveinstance.- Parameters:
jsonPrimitive- The underlyingJsonPrimitiveinstance.
-
-
Method Details
-
isResultPrimitive
public boolean isResultPrimitive()Description copied from interface:ResultElementChecks whether thisResultElementrepresents an unstructured value and, therefore, is aResultPrimitive.- Specified by:
isResultPrimitivein interfaceResultElement- Returns:
- True of this object is a
ResultPrimitive, otherwise false.
-
isResultCollection
public boolean isResultCollection()Description copied from interface:ResultElementChecks whether thisResultElementrepresents a collection of result elements and, therefore, is aResultCollection.- Specified by:
isResultCollectionin interfaceResultElement- Returns:
- True of this object is a
ResultCollection, otherwise false.
-
isResultObject
public boolean isResultObject()Description copied from interface:ResultElementChecks whether thisResultElementrepresents a structured object and, therefore, is aResultObject.- Specified by:
isResultObjectin interfaceResultElement- Returns:
- True of this object is a
ResultObject, otherwise false.
-
getAsPrimitive
Description copied from interface:ResultElementReturns thisResultElementas an instance ofResultPrimitive.- Specified by:
getAsPrimitivein interfaceResultElement- Returns:
- An instance of
ResultPrimitive.
-
getAsCollection
Description copied from interface:ResultElementReturns thisResultElementas an instance ofResultCollection.- Specified by:
getAsCollectionin interfaceResultElement- Returns:
- An instance of
ResultCollection. - Throws:
UnsupportedOperationException- If the cast intoResultCollectionfailed, e.g. in case it is not a collection.
-
getAsObject
Description copied from interface:ResultElementReturns thisResultElementas an instance ofResultObject.- Specified by:
getAsObjectin interfaceResultElement- Returns:
- An instance of
ResultObject. - Throws:
UnsupportedOperationException- If the cast intoResultObjectfailed, e.g. in case it is not an object.
-
asBoolean
Description copied from interface:ResultElementIn case thisResultElementis considered aResultPrimitive, use this method to access its value asboolean.- Specified by:
asBooleanin interfaceResultElement- Specified by:
asBooleanin interfaceResultPrimitive- Returns:
booleanvalue.- Throws:
UnsupportedOperationException- If thisResultElementis not considered aResultPrimitiveor its value cannot be represented asboolean.
-
asByte
Description copied from interface:ResultElementIn case thisResultElementis considered aResultPrimitive, use this method to access its value asbyte.- Specified by:
asBytein interfaceResultElement- Specified by:
asBytein interfaceResultPrimitive- Returns:
bytevalue.- Throws:
UnsupportedOperationException- If thisResultElementis not considered aResultPrimitiveor its value cannot be represented asbyte.
-
asCharacter
Description copied from interface:ResultElementIn case thisResultElementis considered aResultPrimitive, use this method to access its value aschar.- Specified by:
asCharacterin interfaceResultElement- Specified by:
asCharacterin interfaceResultPrimitive- Returns:
charvalue.- Throws:
UnsupportedOperationException- If thisResultElementis not considered aResultPrimitiveor its value cannot be represented aschar.
-
asString
Description copied from interface:ResultElementIn case thisResultElementis considered aResultPrimitive, use this method to access its value asString.- Specified by:
asStringin interfaceResultElement- Specified by:
asStringin interfaceResultPrimitive- Returns:
Stringobject.- Throws:
UnsupportedOperationException- If thisResultElementis not considered aResultPrimitiveor its value cannot be represented asString.
-
asInteger
Description copied from interface:ResultElementIn case thisResultElementis considered aResultPrimitive, use this method to access its value asint.- Specified by:
asIntegerin interfaceResultElement- Specified by:
asIntegerin interfaceResultPrimitive- Returns:
intvalue.- Throws:
UnsupportedOperationException- If thisResultElementis not considered aResultPrimitiveor its value cannot be represented asint.
-
asShort
Description copied from interface:ResultElementIn case thisResultElementis considered aResultPrimitive, use this method to access its value asshort.- Specified by:
asShortin interfaceResultElement- Specified by:
asShortin interfaceResultPrimitive- Returns:
shortvalue.- Throws:
UnsupportedOperationException- If thisResultElementis not considered aResultPrimitiveor its value cannot be represented asshort.
-
asLong
Description copied from interface:ResultElementIn case thisResultElementis considered aResultPrimitive, use this method to access its value aslong.- Specified by:
asLongin interfaceResultElement- Specified by:
asLongin interfaceResultPrimitive- Returns:
longvalue.- Throws:
UnsupportedOperationException- If thisResultElementis not considered aResultPrimitiveor its value cannot be represented aslong.
-
asFloat
Description copied from interface:ResultElementIn case thisResultElementis considered aResultPrimitive, use this method to access its value asfloat.- Specified by:
asFloatin interfaceResultElement- Specified by:
asFloatin interfaceResultPrimitive- Returns:
floatvalue.- Throws:
UnsupportedOperationException- If thisResultElementis not considered aResultPrimitiveor its value cannot be represented asfloat.
-
asDouble
Description copied from interface:ResultElementIn case thisResultElementis considered aResultPrimitive, use this method to access its value asdouble.- Specified by:
asDoublein interfaceResultElement- Specified by:
asDoublein interfaceResultPrimitive- Returns:
doublevalue.- Throws:
UnsupportedOperationException- If thisResultElementis not considered aResultPrimitiveor its value cannot be represented asdouble.
-
asBigInteger
Description copied from interface:ResultElementIn case thisResultElementis considered aResultPrimitive, use this method to access its value asBigInteger.- Specified by:
asBigIntegerin interfaceResultElement- Specified by:
asBigIntegerin interfaceResultPrimitive- Returns:
BigIntegerobject.- Throws:
UnsupportedOperationException- If thisResultElementis not considered aResultPrimitiveor its value cannot be represented asBigInteger.
-
asBigDecimal
Description copied from interface:ResultElementIn case thisResultElementis considered aResultPrimitive, use this method to access its value asBigDecimal.- Specified by:
asBigDecimalin interfaceResultElement- Specified by:
asBigDecimalin interfaceResultPrimitive- Returns:
BigDecimalobject.- Throws:
UnsupportedOperationException- If thisResultElementis not considered aResultPrimitiveor its value cannot be represented asBigDecimal.
-
getJsonPrimitive
public com.google.gson.JsonPrimitive getJsonPrimitive()The underlyingJsonPrimitiveinstance. -
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-