/** * 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); }
private static YamlOrchestrationShardingRuleConfiguration unmarshal(final byte[] yamlByteArray) { return new Yaml(new Constructor(YamlOrchestrationShardingRuleConfiguration.class)).loadAs(new ByteArrayInputStream(yamlByteArray), YamlOrchestrationShardingRuleConfiguration.class); } }
/** * 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); } } }
private static YamlOrchestrationMasterSlaveRuleConfiguration unmarshal(final byte[] yamlByteArray) { return new Yaml(new Constructor(YamlOrchestrationMasterSlaveRuleConfiguration.class)).loadAs(new ByteArrayInputStream(yamlByteArray), YamlOrchestrationMasterSlaveRuleConfiguration.class); } }
/** * 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); } } }
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); } }
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); } }
/** * Create Yaml instance. * * @param dumperOptions * DumperOptions to configure outgoing objects */ public Yaml(DumperOptions dumperOptions) { this(new Constructor(), new Representer(), dumperOptions); }
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; } }
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; } }
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); }
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); }
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; }
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; }
/** * 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()); }
/** * Create Yaml instance. * * @param loadingConfig * LoadingConfig to control load behavior */ public Yaml(LoaderOptions loadingConfig) { this(new Constructor(), new Representer(), new DumperOptions(), loadingConfig); }
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; } }
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; } }
/** * 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()); }
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; }