Interface ResultCustomizer


public interface ResultCustomizer
Result Customizer SPI 响应定制器SPI

Service Provider Interface for customizing results before returning.

在返回之前定制响应的服务提供者接口。

Usage | 使用方式:

public class TraceIdCustomizer implements ResultCustomizer {
    @Override
    public <T> Result<T> customize(Result<T> result) {
        // Add trace ID to result
        return result;
    }
}

Features | 主要功能:

  • SPI for result customization - 响应定制SPI
  • Conditional application support - 条件应用支持
  • Priority ordering support - 优先级排序支持

Usage Examples | 使用示例:

public class AuditCustomizer implements ResultCustomizer {
    public <T> Result<T> customize(Result<T> result) {
        return result.withTraceId(generateTraceId());
    }
}

Security | 安全性:

  • Thread-safe: Implementation-dependent - 取决于实现
  • Null-safe: No (result should not be null) - 否(结果不应为null)
Since:
JDK 25, opencode-base-web V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> Result<T>
    customize(Result<T> result)
    Customize the result 定制响应
    default int
    Get the customizer order 获取定制器顺序
    default boolean
    shouldApply(Result<?> result)
    Check if should apply to this result 检查是否应用于此响应
  • Method Details

    • customize

      <T> Result<T> customize(Result<T> result)
      Customize the result 定制响应
      Type Parameters:
      T - the data type | 数据类型
      Parameters:
      result - the original result | 原始响应
      Returns:
      the customized result | 定制后的响应
    • getOrder

      default int getOrder()
      Get the customizer order 获取定制器顺序

      Lower values execute first.

      值越小越先执行。

      Returns:
      the order | 顺序
    • shouldApply

      default boolean shouldApply(Result<?> result)
      Check if should apply to this result 检查是否应用于此响应
      Parameters:
      result - the result to check | 要检查的响应
      Returns:
      true if should apply | 如果应该应用返回true