org.yaml.snakeyaml.constructor.Constructor.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(296)

本文整理了Java中org.yaml.snakeyaml.constructor.Constructor.<init>()方法的一些代码示例,展示了Constructor.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Constructor.<init>()方法的具体详情如下:
包路径:org.yaml.snakeyaml.constructor.Constructor
类名称:Constructor
方法名:<init>

Constructor.<init>介绍

[英]Create Constructor for the specified class as the root.
[中]为指定的类创建构造函数作为根。

代码示例

代码示例来源:origin: redisson/redisson

/**
 * Create Yaml instance. It is safe to create a few instances and use them
 * in different Threads.
 *
 * @param representer
 *            Representer to emit outgoing objects
 */
public Yaml(Representer representer) {
  this(new Constructor(), representer);
}

代码示例来源:origin: apache/incubator-shardingsphere

private static YamlOrchestrationShardingRuleConfiguration unmarshal(final byte[] yamlByteArray) {
    return new Yaml(new Constructor(YamlOrchestrationShardingRuleConfiguration.class)).loadAs(new ByteArrayInputStream(yamlByteArray), YamlOrchestrationShardingRuleConfiguration.class);
  }
}

代码示例来源:origin: apache/incubator-shardingsphere

/**
   * Unmarshal YAML sharding configuration.
   * 
   * @param yamlBytes YAML bytes
   * @return sharding configuration for YAML
   * @throws IOException IO Exception
   */
  public static YamlShardingConfiguration unmarshal(final byte[] yamlBytes) throws IOException {
    try (InputStream inputStream = new ByteArrayInputStream(yamlBytes)) {
      return new Yaml(new Constructor(YamlShardingConfiguration.class)).loadAs(inputStream, YamlShardingConfiguration.class);
    }
  }
}

代码示例来源:origin: apache/incubator-shardingsphere

private static YamlOrchestrationMasterSlaveRuleConfiguration unmarshal(final byte[] yamlByteArray) {
    return new Yaml(new Constructor(YamlOrchestrationMasterSlaveRuleConfiguration.class)).loadAs(new ByteArrayInputStream(yamlByteArray), YamlOrchestrationMasterSlaveRuleConfiguration.class);
  }
}

代码示例来源:origin: apache/incubator-shardingsphere

/**
   * Unmarshal YAML master-slave configuration.
   *
   * @param yamlBytes YAML bytes
   * @return master-slave configuration for YAML
   * @throws IOException IO Exception
   */
  public static YamlMasterSlaveConfiguration unmarshal(final byte[] yamlBytes) throws IOException {
    try (InputStream inputStream = new ByteArrayInputStream(yamlBytes)) {
      return new Yaml(new Constructor(YamlMasterSlaveConfiguration.class)).loadAs(inputStream, YamlMasterSlaveConfiguration.class);
    }
  }
}

代码示例来源:origin: apache/incubator-shardingsphere

private static YamlOrchestrationShardingRuleConfiguration unmarshal(final File yamlFile) throws IOException {
  try (
      FileInputStream fileInputStream = new FileInputStream(yamlFile);
      InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8")
  ) {
    return new Yaml(new Constructor(YamlOrchestrationShardingRuleConfiguration.class)).loadAs(inputStreamReader, YamlOrchestrationShardingRuleConfiguration.class);
  }
}

代码示例来源:origin: apache/incubator-shardingsphere

private static YamlOrchestrationMasterSlaveRuleConfiguration unmarshal(final File yamlFile) throws IOException {
  try (
      FileInputStream fileInputStream = new FileInputStream(yamlFile);
      InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8")
  ) {
    return new Yaml(new Constructor(YamlOrchestrationMasterSlaveRuleConfiguration.class)).loadAs(inputStreamReader, YamlOrchestrationMasterSlaveRuleConfiguration.class);
  }
}

代码示例来源:origin: redisson/redisson

/**
 * Create Yaml instance.
 *
 * @param dumperOptions
 *            DumperOptions to configure outgoing objects
 */
public Yaml(DumperOptions dumperOptions) {
  this(new Constructor(), new Representer(), dumperOptions);
}

代码示例来源:origin: apache/incubator-shardingsphere

private YamlProxyServerConfiguration loadServerConfiguration(final File yamlFile) throws IOException {
  try (
      FileInputStream fileInputStream = new FileInputStream(yamlFile);
      InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8")
  ) {
    YamlProxyServerConfiguration result = new Yaml(new Constructor(YamlProxyServerConfiguration.class)).loadAs(inputStreamReader, YamlProxyServerConfiguration.class);
    Preconditions.checkNotNull(result, "Server configuration file `%s` is invalid.", yamlFile.getName());
    Preconditions.checkState(!Strings.isNullOrEmpty(result.getAuthentication().getUsername()) || null != result.getOrchestration(), "Authority configuration is invalid.");
    return result;
  }
}

代码示例来源:origin: apache/incubator-shardingsphere

private YamlProxyServerConfiguration loadServerConfiguration(final File yamlFile) throws IOException {
  try (
      FileInputStream fileInputStream = new FileInputStream(yamlFile);
      InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8")
  ) {
    YamlProxyServerConfiguration result = new Yaml(new Constructor(YamlProxyServerConfiguration.class)).loadAs(inputStreamReader, YamlProxyServerConfiguration.class);
    Preconditions.checkNotNull(result, "Server configuration file `%s` is invalid.", yamlFile.getName());
    Preconditions.checkState(!Strings.isNullOrEmpty(result.getAuthentication().getUsername()) || null != result.getOrchestration(), "Authority configuration is invalid.");
    return result;
  }
}

代码示例来源:origin: apache/incubator-dubbo

private static <T> T parseObject(String rawConfig) {
  Constructor constructor = new Constructor(ConfiguratorConfig.class);
  TypeDescription itemDescription = new TypeDescription(ConfiguratorConfig.class);
  itemDescription.addPropertyParameters("items", ConfigItem.class);
  constructor.addTypeDescription(itemDescription);
  Yaml yaml = new Yaml(constructor);
  return yaml.load(rawConfig);
}

代码示例来源:origin: apache/incubator-dubbo

private static <T> T parseObject(String rawConfig) {
  Constructor constructor = new Constructor(ConfiguratorConfig.class);
  TypeDescription itemDescription = new TypeDescription(ConfiguratorConfig.class);
  itemDescription.addPropertyParameters("items", ConfigItem.class);
  constructor.addTypeDescription(itemDescription);
  Yaml yaml = new Yaml(constructor);
  return yaml.load(rawConfig);
}

代码示例来源:origin: apache/incubator-dubbo

public static ConditionRouterRule parse(String rawRule) {
  Constructor constructor = new Constructor(ConditionRouterRule.class);
  Yaml yaml = new Yaml(constructor);
  ConditionRouterRule rule = yaml.load(rawRule);
  rule.setRawRule(rawRule);
  if (CollectionUtils.isEmpty(rule.getConditions())) {
    rule.setValid(false);
  }
  return rule;
}

代码示例来源:origin: apache/incubator-dubbo

public static ConditionRouterRule parse(String rawRule) {
  Constructor constructor = new Constructor(ConditionRouterRule.class);
  Yaml yaml = new Yaml(constructor);
  ConditionRouterRule rule = yaml.load(rawRule);
  rule.setRawRule(rawRule);
  if (CollectionUtils.isEmpty(rule.getConditions())) {
    rule.setValid(false);
  }
  return rule;
}

代码示例来源:origin: redisson/redisson

/**
 * Create Yaml instance. It is safe to create a few instances and use them
 * in different Threads.
 *
 * @param representer
 *            Representer to emit outgoing objects
 * @param dumperOptions
 *            DumperOptions to configure outgoing objects
 */
public Yaml(Representer representer, DumperOptions dumperOptions) {
  this(new Constructor(), representer, dumperOptions, new LoaderOptions(), new Resolver());
}

代码示例来源:origin: redisson/redisson

/**
 * Create Yaml instance.
 *
 * @param loadingConfig
 *            LoadingConfig to control load behavior
 */
public Yaml(LoaderOptions loadingConfig) {
  this(new Constructor(), new Representer(), new DumperOptions(), loadingConfig);
}

代码示例来源:origin: apache/incubator-dubbo

public static TagRouterRule parse(String rawRule) {
    Constructor constructor = new Constructor(TagRouterRule.class);
    TypeDescription tagDescription = new TypeDescription(TagRouterRule.class);
    tagDescription.addPropertyParameters("tags", Tag.class);
    constructor.addTypeDescription(tagDescription);

    Yaml yaml = new Yaml(constructor);
    TagRouterRule rule = yaml.load(rawRule);
    rule.setRawRule(rawRule);
    if (CollectionUtils.isEmpty(rule.getTags())) {
      rule.setValid(false);
    }

    rule.init();
    return rule;
  }
}

代码示例来源:origin: apache/incubator-dubbo

public static TagRouterRule parse(String rawRule) {
    Constructor constructor = new Constructor(TagRouterRule.class);
    TypeDescription tagDescription = new TypeDescription(TagRouterRule.class);
    tagDescription.addPropertyParameters("tags", Tag.class);
    constructor.addTypeDescription(tagDescription);

    Yaml yaml = new Yaml(constructor);
    TagRouterRule rule = yaml.load(rawRule);
    rule.setRawRule(rawRule);
    if (CollectionUtils.isEmpty(rule.getTags())) {
      rule.setValid(false);
    }

    rule.init();
    return rule;
  }
}

代码示例来源:origin: redisson/redisson

/**
 * Create Yaml instance. It is safe to create a few instances and use them
 * in different Threads.
 */
public Yaml() {
  this(new Constructor(), new Representer(), new DumperOptions(), new LoaderOptions(),
      new Resolver());
}

代码示例来源:origin: apache/storm

private static Yaml yaml() {
  TypeDescription topologyDescription = new TypeDescription(TopologyDef.class);
  topologyDescription.putListPropertyType("spouts", SpoutDef.class);
  topologyDescription.putListPropertyType("bolts", BoltDef.class);
  topologyDescription.putListPropertyType("includes", IncludeDef.class);
  Constructor constructor = new Constructor(TopologyDef.class);
  constructor.addTypeDescription(topologyDescription);
  Yaml yaml = new Yaml(constructor);
  return yaml;
}

相关文章