Class Binder

java.lang.Object
org.miaixz.bus.core.Binder

public class Binder extends Object
属性绑定器
Since:
Java 17+
Author:
Kimi Liu
  • Field Details

    • DEFAULT_PLACEHOLDER_PREFIX

      public static final String DEFAULT_PLACEHOLDER_PREFIX
      默认占位符前缀: "${"
      See Also:
    • DEFAULT_PLACEHOLDER_SUFFIX

      public static final String DEFAULT_PLACEHOLDER_SUFFIX
      默认占位符后缀: "}"
      See Also:
    • DEFAULT_VALUE_SEPARATOR

      public static final String DEFAULT_VALUE_SEPARATOR
      默认占位值分隔符: ":"
      See Also:
    • DEFAULT_HELPER

      public static final Binder DEFAULT_HELPER
      默认实例
  • Constructor Details

    • Binder

      public Binder(String placeholderPrefix, String placeholderSuffix)
      构造
      Parameters:
      placeholderPrefix - 占位符前缀
      placeholderSuffix - 占位符后缀
    • Binder

      public Binder(String placeholderPrefix, String placeholderSuffix, String valueSeparator, boolean ignoreUnresolvablePlaceholders)
      构造
      Parameters:
      placeholderPrefix - 占位符前缀
      placeholderSuffix - 占位符后缀
      valueSeparator - 值分隔符
      ignoreUnresolvablePlaceholders - 忽略不可解析的占位符
  • Method Details

    • bind

      public <T> T bind(Class<T> clazz)
      绑定属性到类
      Type Parameters:
      T - 泛型
      Parameters:
      clazz - 类型
      Returns:
      the object
    • bind

      public <T> T bind(Class<T> clazz, String prefix)
      绑定指定前缀属性到类
      Type Parameters:
      T - 泛型
      Parameters:
      clazz - 类型
      prefix - 前缀
      Returns:
      the object
    • bind

      public <T> T bind(T object, String prefix)
      绑定属性到对象实例
      Type Parameters:
      T - 泛型
      Parameters:
      object - 对象实例
      prefix - 属性前缀
      Returns:
      the object
    • replacePlaceholders

      public String replacePlaceholders(String value, Properties properties)
      替换所有占位格式 ${name}
      Parameters:
      value - 需要转换的属性
      properties - 配置集合
      Returns:
      替换后的字符串
    • parseStringValue

      protected String parseStringValue(String value, Properties properties, Set<String> visitedPlaceholders)
      替换字符串
      Parameters:
      value - 字符串
      properties - 属性
      visitedPlaceholders - 参数占位符
      Returns:
      替换后的字符串