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 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.Returns thisResultElementas an instance ofResultCollection.Returns thisResultElementas an instance ofResultObject.Returns thisResultElementas an instance ofResultPrimitive.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.
-
Method Details
-
isResultPrimitive
boolean isResultPrimitive()Checks whether thisResultElementrepresents an unstructured value and, therefore, is aResultPrimitive.- Returns:
- True of this object is a
ResultPrimitive, otherwise false.
-
isResultCollection
boolean isResultCollection()Checks whether thisResultElementrepresents a collection of result elements and, therefore, is aResultCollection.- Returns:
- True of this object is a
ResultCollection, otherwise false.
-
isResultObject
boolean isResultObject()Checks whether thisResultElementrepresents a structured object and, therefore, is aResultObject.- Returns:
- True of this object is a
ResultObject, otherwise false.
-
getAsPrimitive
Returns thisResultElementas an instance ofResultPrimitive.- Returns:
- An instance of
ResultPrimitive. - Throws:
UnsupportedOperationException- If the cast intoResultPrimitivefailed, e.g. in case it is not a primitive.
-
getAsCollection
Returns thisResultElementas an instance ofResultCollection.- Returns:
- An instance of
ResultCollection. - Throws:
UnsupportedOperationException- If the cast intoResultCollectionfailed, e.g. in case it is not a collection.
-
getAsObject
Returns thisResultElementas an instance ofResultObject.- Returns:
- An instance of
ResultObject. - Throws:
UnsupportedOperationException- If the cast intoResultObjectfailed, e.g. in case it is not an object.
-
asBoolean
In case thisResultElementis considered aResultPrimitive, use this method to access its value asboolean.- Returns:
booleanvalue.- Throws:
UnsupportedOperationException- If thisResultElementis not considered aResultPrimitiveor its value cannot be represented asboolean.
-
asByte
In case thisResultElementis considered aResultPrimitive, use this method to access its value asbyte.- Returns:
bytevalue.- Throws:
UnsupportedOperationException- If thisResultElementis not considered aResultPrimitiveor its value cannot be represented asbyte.
-
asCharacter
In case thisResultElementis considered aResultPrimitive, use this method to access its value aschar.- Returns:
charvalue.- Throws:
UnsupportedOperationException- If thisResultElementis not considered aResultPrimitiveor its value cannot be represented aschar.
-
asString
In case thisResultElementis considered aResultPrimitive, use this method to access its value asString.- Returns:
Stringobject.- Throws:
UnsupportedOperationException- If thisResultElementis not considered aResultPrimitiveor its value cannot be represented asString.
-
asInteger
In case thisResultElementis considered aResultPrimitive, use this method to access its value asint.- Returns:
intvalue.- Throws:
UnsupportedOperationException- If thisResultElementis not considered aResultPrimitiveor its value cannot be represented asint.
-
asShort
In case thisResultElementis considered aResultPrimitive, use this method to access its value asshort.- Returns:
shortvalue.- Throws:
UnsupportedOperationException- If thisResultElementis not considered aResultPrimitiveor its value cannot be represented asshort.
-
asLong
In case thisResultElementis considered aResultPrimitive, use this method to access its value aslong.- Returns:
longvalue.- Throws:
UnsupportedOperationException- If thisResultElementis not considered aResultPrimitiveor its value cannot be represented aslong.
-
asFloat
In case thisResultElementis considered aResultPrimitive, use this method to access its value asfloat.- Returns:
floatvalue.- Throws:
UnsupportedOperationException- If thisResultElementis not considered aResultPrimitiveor its value cannot be represented asfloat.
-
asDouble
In case thisResultElementis considered aResultPrimitive, use this method to access its value asdouble.- Returns:
doublevalue.- Throws:
UnsupportedOperationException- If thisResultElementis not considered aResultPrimitiveor its value cannot be represented asdouble.
-
asBigInteger
In case thisResultElementis considered aResultPrimitive, use this method to access its value asBigInteger.- Returns:
BigIntegerobject.- Throws:
UnsupportedOperationException- If thisResultElementis not considered aResultPrimitiveor its value cannot be represented asBigInteger.
-
asBigDecimal
In case thisResultElementis considered aResultPrimitive, use this method to access its value asBigDecimal.- Returns:
BigDecimalobject.- Throws:
UnsupportedOperationException- If thisResultElementis not considered aResultPrimitiveor its value cannot be represented asBigDecimal.
-