本文整理了Java中org.yaml.snakeyaml.constructor.Constructor.setPropertyUtils()
方法的一些代码示例,展示了Constructor.setPropertyUtils()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Constructor.setPropertyUtils()
方法的具体详情如下:
包路径:org.yaml.snakeyaml.constructor.Constructor
类名称:Constructor
方法名:setPropertyUtils
暂无
代码示例来源:origin: lealone/Lealone
public Config loadConfig(URL url) throws ConfigException {
try {
logger.info("Loading config from {}", url);
byte[] configBytes;
try (InputStream is = url.openStream()) {
configBytes = IOUtils.toByteArray(is);
} catch (IOException e) {
// getConfigURL should have ruled this out
throw new AssertionError(e);
}
Constructor configConstructor = new Constructor(getConfigClass());
addTypeDescription(configConstructor);
MissingPropertiesChecker propertiesChecker = new MissingPropertiesChecker();
configConstructor.setPropertyUtils(propertiesChecker);
Yaml yaml = new Yaml(configConstructor);
Config result = (Config) yaml.loadAs(new ByteArrayInputStream(configBytes), getConfigClass());
propertiesChecker.check();
return result;
} catch (YAMLException e) {
throw new ConfigException("Invalid yaml", e);
}
}
代码示例来源:origin: SpigotMC/BungeeCord
@SuppressWarnings("unchecked")
public PluginManager(ProxyServer proxy)
{
this.proxy = proxy;
// Ignore unknown entries in the plugin descriptions
Constructor yamlConstructor = new Constructor();
PropertyUtils propertyUtils = yamlConstructor.getPropertyUtils();
propertyUtils.setSkipMissingProperties( true );
yamlConstructor.setPropertyUtils( propertyUtils );
yaml = new Yaml( yamlConstructor );
eventBus = new EventBus( proxy.getLogger() );
}
代码示例来源:origin: smartcat-labs/berserker
constructor.setPropertyUtils(new PropertyUtils() {
@Override
public Property getProperty(Class<? extends Object> type, String name) throws IntrospectionException {
代码示例来源:origin: io.smartcat/berserker-commons
constructor.setPropertyUtils(new PropertyUtils() {
@Override
public Property getProperty(Class<? extends Object> type, String name) throws IntrospectionException {
代码示例来源:origin: WaterfallMC/Waterfall-Old
public PluginManager(ProxyServer proxy)
{
this.proxy = proxy;
// Ignore unknown entries in the plugin descriptions
Constructor yamlConstructor = new Constructor();
PropertyUtils propertyUtils = yamlConstructor.getPropertyUtils();
propertyUtils.setSkipMissingProperties( true );
yamlConstructor.setPropertyUtils( propertyUtils );
yaml = new Yaml( yamlConstructor );
eventBus = new EventBus( proxy.getLogger() );
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
constructor.addTypeDescription(seedDesc);
MissingPropertiesChecker propertiesChecker = new MissingPropertiesChecker();
constructor.setPropertyUtils(propertiesChecker);
Yaml yaml = new Yaml(constructor);
Config result = yaml.loadAs(new ByteArrayInputStream(configBytes), Config.class);
代码示例来源:origin: org.apache.cassandra/cassandra-all
public Config loadConfig(URL url) throws ConfigurationException
{
try
{
logger.debug("Loading settings from {}", url);
byte[] configBytes;
try (InputStream is = url.openStream())
{
configBytes = ByteStreams.toByteArray(is);
}
catch (IOException e)
{
// getStorageConfigURL should have ruled this out
throw new AssertionError(e);
}
Constructor constructor = new CustomConstructor(Config.class);
PropertiesChecker propertiesChecker = new PropertiesChecker();
constructor.setPropertyUtils(propertiesChecker);
Yaml yaml = new Yaml(constructor);
Config result = loadConfig(yaml, configBytes);
propertiesChecker.check();
return result;
}
catch (YAMLException e)
{
throw new ConfigurationException("Invalid yaml: " + url + SystemUtils.LINE_SEPARATOR
+ " Error: " + e.getMessage(), false);
}
}
代码示例来源:origin: com.netflix.sstableadaptor/sstable-adaptor-cassandra
public Config loadConfig(URL url) throws ConfigurationException
{
try
{
logger.debug("Loading settings from {}", url);
byte[] configBytes;
try (InputStream is = url.openStream())
{
configBytes = ByteStreams.toByteArray(is);
}
catch (IOException e)
{
// getStorageConfigURL should have ruled this out
throw new AssertionError(e);
}
Constructor constructor = new CustomConstructor(Config.class);
PropertiesChecker propertiesChecker = new PropertiesChecker();
constructor.setPropertyUtils(propertiesChecker);
Yaml yaml = new Yaml(constructor);
Config result = loadConfig(yaml, configBytes);
propertiesChecker.check();
return result;
}
catch (YAMLException e)
{
throw new ConfigurationException("Invalid yaml: " + url + SystemUtils.LINE_SEPARATOR
+ " Error: " + e.getMessage(), false);
}
}
代码示例来源:origin: com.strapdata.cassandra/cassandra-all
public Config loadConfig(URL url) throws ConfigurationException
{
try
{
logger.debug("Loading settings from {}", url);
byte[] configBytes;
try (InputStream is = url.openStream())
{
configBytes = ByteStreams.toByteArray(is);
}
catch (IOException e)
{
// getStorageConfigURL should have ruled this out
throw new AssertionError(e);
}
Constructor constructor = new CustomConstructor(Config.class);
PropertiesChecker propertiesChecker = new PropertiesChecker();
constructor.setPropertyUtils(propertiesChecker);
Yaml yaml = new Yaml(constructor);
Config result = loadConfig(yaml, configBytes);
propertiesChecker.check();
return result;
}
catch (YAMLException e)
{
throw new ConfigurationException("Invalid yaml: " + url + SystemUtils.LINE_SEPARATOR
+ " Error: " + e.getMessage(), false);
}
}
代码示例来源:origin: jsevellec/cassandra-unit
public Config loadConfig(URL url) throws ConfigurationException
{
try
{
logger.debug("Loading settings from {}", url);
byte[] configBytes;
try (InputStream is = url.openStream())
{
configBytes = ByteStreams.toByteArray(is);
}
catch (IOException e)
{
// getStorageConfigURL should have ruled this out
throw new AssertionError(e);
}
Constructor constructor = new CustomConstructor(Config.class);
PropertiesChecker propertiesChecker = new PropertiesChecker();
constructor.setPropertyUtils(propertiesChecker);
Yaml yaml = new Yaml(constructor);
Config result = loadConfig(yaml, configBytes);
propertiesChecker.check();
return result;
}
catch (YAMLException e)
{
throw new ConfigurationException("Invalid yaml: " + url + SystemUtils.LINE_SEPARATOR
+ " Error: " + e.getMessage(), false);
}
}
代码示例来源:origin: com.facebook.presto.cassandra/cassandra-server
constructor.addTypeDescription(seedDesc);
MissingPropertiesChecker propertiesChecker = new MissingPropertiesChecker();
constructor.setPropertyUtils(propertiesChecker);
Yaml yaml = new Yaml(constructor);
Config result = yaml.loadAs(new ByteArrayInputStream(configBytes), Config.class);
代码示例来源:origin: com.buschmais.jqassistant.plugin/common
@Override
public <T extends ExecutableRule<?>> Result<T> execute(T executableRule, Map<String, Object> ruleParameters, Severity severity, AnalyzerContext context)
throws RuleException {
SourceExecutable<String> executable = (SourceExecutable<String>) executableRule.getExecutable();
String source = executable.getSource();
Constructor c = new Constructor(YamlRuleSource.class);
c.setPropertyUtils(new PropertyUtils() {
@Override
public Property getProperty(Class<? extends Object> type, String name) {
return super.getProperty(type, LOWER_HYPHEN.to(LOWER_CAMEL, name));
}
});
YamlRuleSource yamlRuleSource = new Yaml(c).loadAs(source, YamlRuleSource.class);
String javaRuleClass = yamlRuleSource.getJavaRule();
if (javaRuleClass == null) {
throw new RuleException("'java-rule-class' is required.");
}
JavaRule javaRule = getJavaRule(javaRuleClass);
return javaRule.execute(executableRule, yamlRuleSource.getConfiguration(), ruleParameters, severity, context);
}
内容来源于网络,如有侵权,请联系作者删除!