Class EventResult

java.lang.Object
top.magstar.framework.events.models.EventResult

public class EventResult extends Object
事件处理结果 - 封装事件处理的详细信息
  • Method Details

    • success

      public static EventResult success(int syncHandlers, int asyncHandlers)
      创建成功结果
    • failed

      public static EventResult failed(String message)
      创建失败结果
    • failed

      public static EventResult failed(String message, Exception exception)
      创建失败结果(带异常)
    • isSuccess

      public boolean isSuccess()
      是否处理成功
    • isFailure

      public boolean isFailure()
      是否处理失败
    • getMessage

      public String getMessage()
      获取结果消息
    • getSyncHandlersExecuted

      public int getSyncHandlersExecuted()
      获取同步处理器执行数量
    • getAsyncHandlersExecuted

      public int getAsyncHandlersExecuted()
      获取异步处理器执行数量
    • getTotalHandlersExecuted

      public int getTotalHandlersExecuted()
      获取总处理器执行数量
    • getExecutionTimeMs

      public long getExecutionTimeMs()
      获取执行时间(毫秒)
    • getTimestamp

      public long getTimestamp()
      获取时间戳
    • getExceptions

      public List<Exception> getExceptions()
      获取异常列表
    • hasExceptions

      public boolean hasExceptions()
      是否有异常
    • getFirstException

      public Optional<Exception> getFirstException()
      获取第一个异常
    • getReturnValue

      public Optional<Object> getReturnValue()
      获取返回值
    • getReturnValue

      public <T> Optional<T> getReturnValue(Class<T> type)
      获取类型安全的返回值
    • withExecutionTime

      public EventResult withExecutionTime(long executionTimeMs)
      设置执行时间
    • withException

      public EventResult withException(Exception exception)
      添加异常
    • withExceptions

      public EventResult withExceptions(List<Exception> exceptions)
      添加异常列表
    • withReturnValue

      public EventResult withReturnValue(Object returnValue)
      设置返回值
    • merge

      public EventResult merge(EventResult other)
      合并两个结果
    • getSuccessRate

      public double getSuccessRate()
      获取成功率
    • hasHandlers

      public boolean hasHandlers()
      是否有处理器执行
    • hasAsyncHandlers

      public boolean hasAsyncHandlers()
      是否包含异步处理器
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • mergeAll

      public static EventResult mergeAll(List<EventResult> results)
      合并多个结果
    • timeout

      public static EventResult timeout(long timeoutMs)
      创建超时结果
    • noHandlers

      public static EventResult noHandlers()
      创建无处理器结果