Package com.sap.cloud.sdk.result
Interface ResultElement
- All Known Subinterfaces:
ResultCollection
,ResultObject
,ResultPrimitive
- All Known Implementing Classes:
DefaultResultCollection
,GsonResultObject
,GsonResultPrimitive
public interface ResultElement
Class representing one resulting element from a call to an external service (e.g. after invoking a BAPI or a
remote-enabled function module).
Note that accessing the result element varies depending on its structure:
- If the result element represents an unstructured value (e.g. a String object), it is considered a
ResultPrimitive
.
When dealing with BAPI or RFM request results, this occurs if the respective result element is reflected as a data element in the ABAP Data Dictionary. - If the result element represents a structured object (e.g. one complex business object), it is considered a
ResultObject
.
When dealing with BAPI or RFM request results, this occurs if the respective result element is reflected as a structure in the ABAP Data Dictionary. - If the result element represents a collection of result elements (e.g. a list of complex business objects), it is
considered a
ResultCollection
.
When dealing with BAPI or RFM request results, this occurs if the respective result element is reflected as a table type in the ABAP Data Dictionary or is used as tables parameter in the interface of the BAPI or RFM.
isResultPrimitive()
, isResultObject()
, or isResultCollection()
to check
for the respective case.
As accessing the content of the result element varies depending on its structure, use the methods
getAsPrimitive()
, getAsObject()
, or getAsCollection()
to access the result element
content.
If the result element is considered a ResultPrimitive
, its content can be accessed with the respective method
directly, such as asString()
to obtain the result element content as String object.
-
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
.Returns thisResultElement
as an instance ofResultCollection
.Returns thisResultElement
as an instance ofResultObject
.Returns thisResultElement
as an instance ofResultPrimitive
.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
.
-
Method Details
-
isResultPrimitive
boolean isResultPrimitive()Checks whether thisResultElement
represents an unstructured value and, therefore, is aResultPrimitive
.- Returns:
- True of this object is a
ResultPrimitive
, otherwise false.
-
isResultCollection
boolean isResultCollection()Checks whether thisResultElement
represents a collection of result elements and, therefore, is aResultCollection
.- Returns:
- True of this object is a
ResultCollection
, otherwise false.
-
isResultObject
boolean isResultObject()Checks whether thisResultElement
represents a structured object and, therefore, is aResultObject
.- Returns:
- True of this object is a
ResultObject
, otherwise false.
-
getAsPrimitive
Returns thisResultElement
as an instance ofResultPrimitive
.- Returns:
- An instance of
ResultPrimitive
. - Throws:
UnsupportedOperationException
- If the cast intoResultPrimitive
failed, e.g. in case it is not a primitive.
-
getAsCollection
Returns thisResultElement
as an instance ofResultCollection
.- Returns:
- An instance of
ResultCollection
. - Throws:
UnsupportedOperationException
- If the cast intoResultCollection
failed, e.g. in case it is not a collection.
-
getAsObject
Returns thisResultElement
as an instance ofResultObject
.- Returns:
- An instance of
ResultObject
. - Throws:
UnsupportedOperationException
- If the cast intoResultObject
failed, e.g. in case it is not an object.
-
asBoolean
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asboolean
.- Returns:
boolean
value.- Throws:
UnsupportedOperationException
- If thisResultElement
is not considered aResultPrimitive
or its value cannot be represented asboolean
.
-
asByte
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asbyte
.- Returns:
byte
value.- Throws:
UnsupportedOperationException
- If thisResultElement
is not considered aResultPrimitive
or its value cannot be represented asbyte
.
-
asCharacter
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value aschar
.- Returns:
char
value.- Throws:
UnsupportedOperationException
- If thisResultElement
is not considered aResultPrimitive
or its value cannot be represented aschar
.
-
asString
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asString
.- Returns:
String
object.- Throws:
UnsupportedOperationException
- If thisResultElement
is not considered aResultPrimitive
or its value cannot be represented asString
.
-
asInteger
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asint
.- Returns:
int
value.- Throws:
UnsupportedOperationException
- If thisResultElement
is not considered aResultPrimitive
or its value cannot be represented asint
.
-
asShort
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asshort
.- Returns:
short
value.- Throws:
UnsupportedOperationException
- If thisResultElement
is not considered aResultPrimitive
or its value cannot be represented asshort
.
-
asLong
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value aslong
.- Returns:
long
value.- Throws:
UnsupportedOperationException
- If thisResultElement
is not considered aResultPrimitive
or its value cannot be represented aslong
.
-
asFloat
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asfloat
.- Returns:
float
value.- Throws:
UnsupportedOperationException
- If thisResultElement
is not considered aResultPrimitive
or its value cannot be represented asfloat
.
-
asDouble
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asdouble
.- Returns:
double
value.- Throws:
UnsupportedOperationException
- If thisResultElement
is not considered aResultPrimitive
or its value cannot be represented asdouble
.
-
asBigInteger
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asBigInteger
.- Returns:
BigInteger
object.- Throws:
UnsupportedOperationException
- If thisResultElement
is not considered aResultPrimitive
or its value cannot be represented asBigInteger
.
-
asBigDecimal
In case thisResultElement
is considered aResultPrimitive
, use this method to access its value asBigDecimal
.- Returns:
BigDecimal
object.- Throws:
UnsupportedOperationException
- If thisResultElement
is not considered aResultPrimitive
or its value cannot be represented asBigDecimal
.
-