Module bus.setting

Class Builder

java.lang.Object
org.miaixz.bus.setting.Builder

public class Builder extends Object
构建器创建IniSetting示例 非线程安全
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • loadYaml

      public static org.miaixz.bus.core.center.map.Dictionary loadYaml(String path)
      从classpath或绝对路径加载YAML文件
      Parameters:
      path - YAML路径,相对路径相对classpath
      Returns:
      加载的内容,默认Map
    • loadYaml

      public static <T> T loadYaml(String path, Class<T> type)
      从classpath或绝对路径加载YAML文件
      Type Parameters:
      T - Bean类型,默认map
      Parameters:
      path - YAML路径,相对路径相对classpath
      type - 加载的Bean类型,即转换为的bean
      Returns:
      加载的内容,默认Map
    • loadYaml

      public static <T> T loadYaml(InputStream in, Class<T> type)
      从流中加载YAML
      Type Parameters:
      T - Bean类型,默认map
      Parameters:
      in - 流
      type - 加载的Bean类型,即转换为的bean
      Returns:
      加载的内容,默认Map
    • loadYaml

      public static org.miaixz.bus.core.center.map.Dictionary loadYaml(Reader reader)
      加载YAML,加载完毕后关闭Reader
      Parameters:
      reader - Reader
      Returns:
      加载的Map
    • loadYaml

      public static <T> T loadYaml(Reader reader, Class<T> type)
      加载YAML,加载完毕后关闭Reader
      Type Parameters:
      T - Bean类型,默认map
      Parameters:
      reader - Reader
      type - 加载的Bean类型,即转换为的bean
      Returns:
      加载的内容,默认Map
    • loadYaml

      public static <T> T loadYaml(Reader reader, Class<T> type, boolean isCloseReader)
      加载YAML
      Type Parameters:
      T - Bean类型,默认map
      Parameters:
      reader - Reader
      type - 加载的Bean类型,即转换为的bean
      isCloseReader - 加载完毕后是否关闭Reader
      Returns:
      加载的内容,默认Map
    • parseYaml

      public static <T> T parseYaml(String content)
      解析YAML
      Parameters:
      content - 数据内容
    • parseYaml

      public static <T> T parseYaml(String prefix, Map<String,Object> map)
      解析YAML
      Parameters:
      prefix - 前缀信息
      map - 数据内容
    • dumpYaml

      public static void dumpYaml(Object object, Writer writer)
      将Bean对象或者Map写出到Writer
      Parameters:
      object - 对象
      writer - Writer
    • dumpYaml

      public static void dumpYaml(Object object, Writer writer, org.yaml.snakeyaml.DumperOptions dumperOptions)
      将Bean对象或者Map写出到Writer
      Parameters:
      object - 对象
      writer - Writer
      dumperOptions - 输出风格
    • replaceYamlValue

      public static String replaceYamlValue(Properties properties, String value)
      将Bean对象或者Map写出到Writer
      Parameters:
      properties - 对象
      value - 输出风格
      Returns:
      the string
    • getProperties

      public static Properties getProperties()
      获取系统参数,例如用户在执行java命令时定义的 -Duse=bus
      Returns:
      系统参数Props
    • getProperties

      public static Properties getProperties(String name)
      获取当前环境下的配置文件 name可以为不包括扩展名的文件名(默认.properties),也可以是文件名全称
      Parameters:
      name - 文件名,如果没有扩展名,默认为.properties
      Returns:
      当前环境下配置文件
    • getPropertiesFound

      public static Properties getPropertiesFound(String... names)
      获取给定路径找到的第一个配置文件 * name可以为不包括扩展名的文件名(默认.properties为结尾),也可以是文件名全称
      Parameters:
      names - 文件名,如果没有扩展名,默认为.properties
      Returns:
      当前环境下配置文件
    • getSetting

      public static Setting getSetting(String name)
      获取当前环境下的配置文件 name可以为不包括扩展名的文件名(默认.setting为结尾),也可以是文件名全称
      Parameters:
      name - 文件名,如果没有扩展名,默认为.setting
      Returns:
      当前环境下配置文件
    • getSettingFirstFound

      public static Setting getSettingFirstFound(String... names)
      获取给定路径找到的第一个配置文件 * name可以为不包括扩展名的文件名(默认.setting为结尾),也可以是文件名全称
      Parameters:
      names - 文件名,如果没有扩展名,默认为.setting
      Returns:
      当前环境下配置文件