Package com.algorithmia.algo
Class AlgoSuccess
- java.lang.Object
-
- com.algorithmia.algo.AlgoResponse
-
- com.algorithmia.algo.AlgoSuccess
-
- All Implemented Interfaces:
java.io.Serializable
public final class AlgoSuccess extends AlgoResponse
A result representing success, depending on how the algorithm was called it may have an async response, rawOutput, or metadata + result.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AlgoSuccess(com.google.gson.JsonElement result, Metadata metadata, java.lang.String rawOutput, AlgoAsyncResponse asyncResponse)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <T> T
as(java.lang.Class<T> returnClass)
Convert the result to a specific classprotected <T> T
as(java.lang.reflect.Type returnType)
Convert the result to a specific typejava.lang.String
asJsonString()
Return JSON representation of the result.java.lang.String
asString()
Return String representation of the result.AlgoAsyncResponse
getAsyncResponse()
Metadata
getMetadata()
java.lang.String
getRawOutput()
Return the raw output of the algorithm if it was called with AlgorithmOutputType.RAW This is the only valid way to retrieve a result from a RAW request.boolean
isFailure()
boolean
isSuccess()
-
Methods inherited from class com.algorithmia.algo.AlgoResponse
as
-
-
-
-
Constructor Detail
-
AlgoSuccess
public AlgoSuccess(com.google.gson.JsonElement result, Metadata metadata, java.lang.String rawOutput, AlgoAsyncResponse asyncResponse)
-
-
Method Detail
-
isSuccess
public boolean isSuccess()
- Specified by:
isSuccess
in classAlgoResponse
-
isFailure
public boolean isFailure()
- Specified by:
isFailure
in classAlgoResponse
-
getMetadata
public Metadata getMetadata()
- Specified by:
getMetadata
in classAlgoResponse
-
getAsyncResponse
public AlgoAsyncResponse getAsyncResponse() throws AlgorithmException
- Specified by:
getAsyncResponse
in classAlgoResponse
- Throws:
AlgorithmException
-
as
protected <T> T as(java.lang.Class<T> returnClass)
Description copied from class:AlgoResponse
Convert the result to a specific class- Specified by:
as
in classAlgoResponse
- Type Parameters:
T
- the type that the response will be deserialized into- Parameters:
returnClass
- the class used by the deserializer (should correspond with T)- Returns:
- the result, if this is AlgoSuccess
-
as
protected <T> T as(java.lang.reflect.Type returnType)
Description copied from class:AlgoResponse
Convert the result to a specific type- Specified by:
as
in classAlgoResponse
- Type Parameters:
T
- the type that the response will be deserialized into- Parameters:
returnType
- the type used by the deserializer (should correspond with T)- Returns:
- the result, if this is AlgoSuccess
-
asJsonString
public java.lang.String asJsonString()
Description copied from class:AlgoResponse
Return JSON representation of the result.- Specified by:
asJsonString
in classAlgoResponse
- Returns:
- the result, if this is AlgoSuccess
-
asString
public java.lang.String asString()
Description copied from class:AlgoResponse
Return String representation of the result.- Specified by:
asString
in classAlgoResponse
- Returns:
- the result, if this is AlgoSuccess
-
getRawOutput
public java.lang.String getRawOutput() throws AlgorithmException
Description copied from class:AlgoResponse
Return the raw output of the algorithm if it was called with AlgorithmOutputType.RAW This is the only valid way to retrieve a result from a RAW request. Will return null for any other AlgorithmOutputType- Specified by:
getRawOutput
in classAlgoResponse
- Returns:
- the result, if this is AlgoSuccess
- Throws:
AlgorithmException
- the error, if this is AlgoFailure
-
-