接口 Result
-
- 所有超级接口:
Serializable
- 所有已知子接口:
Result
- 所有已知实现类:
AppResponse,AsyncRpcResult,DecodeableRpcResult,Result.AbstractResult,Result.CompatibleResult
public interface Result extends Serializable
(API, Prototype, NonThreadSafe) An RPCResult. Known implementations are: 1.AsyncRpcResult, it's aCompletionStagewhose underlying value signifies the return value of an RPC call. 2.AppResponse, it inevitably inheritsCompletionStageandFuture, but you should never treat AppResponse as a type of Future, instead, it is a normal concrete type.
-
-
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 voidaddAttachments(Map<String,String> map)Add the specified map to existing attachments in this instance.voidaddObjectAttachments(Map<String,Object> map)Add the specified map to existing attachments in this instance.Resultget()Resultget(long timeout, TimeUnit unit)StringgetAttachment(String key)get attachment by key.StringgetAttachment(String key, String defaultValue)get attachment by key with default value.Map<String,String>getAttachments()get attachments.ThrowablegetException()Get exception.ObjectgetObjectAttachment(String key)get attachment by key.ObjectgetObjectAttachment(String key, Object defaultValue)get attachment by key with default value.Map<String,Object>getObjectAttachments()get attachments.ObjectgetValue()Get invoke result.booleanhasException()Has exception.Objectrecreate()Recreate.voidsetAttachment(String key, Object value)voidsetAttachment(String key, String value)voidsetAttachments(Map<String,String> map)Replace the existing attachments with the specified param.voidsetException(Throwable t)voidsetObjectAttachment(String key, Object value)voidsetObjectAttachments(Map<String,Object> map)Replace the existing attachments with the specified param.voidsetValue(Object value)<U> CompletableFuture<U>thenApply(Function<Result,? extends U> fn)ResultwhenCompleteWithContext(BiConsumer<Result,Throwable> fn)Add a callback which can be triggered when the RPC call finishes.
-
-
-
方法详细资料
-
getValue
Object getValue()
Get invoke result.- 返回:
- result. if no result return null.
-
setValue
void setValue(Object value)
-
getException
Throwable getException()
Get exception.- 返回:
- exception. if no exception return null.
-
setException
void setException(Throwable t)
-
hasException
boolean hasException()
Has exception.- 返回:
- has exception.
-
recreate
Object recreate() throws Throwable
Recreate.if (hasException()) { throw getException(); } else { return getValue(); }- 返回:
- result.
- 抛出:
Throwable
-
addAttachments
void addAttachments(Map<String,String> map)
Add the specified map to existing attachments in this instance.- 参数:
map-
-
addObjectAttachments
void addObjectAttachments(Map<String,Object> map)
Add the specified map to existing attachments in this instance.- 参数:
map-
-
setAttachments
void setAttachments(Map<String,String> map)
Replace the existing attachments with the specified param.- 参数:
map-
-
setObjectAttachments
void setObjectAttachments(Map<String,Object> map)
Replace the existing attachments with the specified param.- 参数:
map-
-
getObjectAttachment
Object getObjectAttachment(String key)
get attachment by key.- 返回:
- attachment value.
-
getAttachment
String getAttachment(String key, String defaultValue)
get attachment by key with default value.- 返回:
- attachment value.
-
getObjectAttachment
Object getObjectAttachment(String key, Object defaultValue)
get attachment by key with default value.- 返回:
- attachment value.
-
whenCompleteWithContext
Result whenCompleteWithContext(BiConsumer<Result,Throwable> fn)
Add a callback which can be triggered when the RPC call finishes.Just as the method name implies, this method will guarantee the callback being triggered under the same context as when the call was started, see implementation in
whenCompleteWithContext(BiConsumer)- 参数:
fn-- 返回:
-
thenApply
<U> CompletableFuture<U> thenApply(Function<Result,? extends U> fn)
-
get
Result get() throws InterruptedException, ExecutionException
-
get
Result get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
-
-