本文整理匯總了Java中org.srcdeps.config.yaml.YamlConfigurationIo類的典型用法代碼示例。如果您正苦於以下問題:Java YamlConfigurationIo類的具體用法?Java YamlConfigurationIo怎麽用?Java YamlConfigurationIo使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
YamlConfigurationIo類屬於org.srcdeps.config.yaml包,在下文中一共展示了YamlConfigurationIo類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: writeFull
import org.srcdeps.config.yaml.YamlConfigurationIo; //導入依賴的package包/類
@Test
public void writeFull() throws ConfigurationException, UnsupportedEncodingException, IOException {
final StringWriter out = new StringWriter();
final Configuration configFromFile;
try (Reader in = new InputStreamReader(getClass().getResourceAsStream("/srcdeps-full.yaml"), "utf-8");
YamlWriterVisitor writerVisitor = new YamlWriterVisitor(out,
YamlWriterConfiguration.builder().build());) {
configFromFile = new YamlConfigurationIo() //
.read(in) //
.accept(writerVisitor) //
.build();
}
/*
* now read the serialized output we have written to the out StringWriter back into a new Configuration instance
*/
try (Reader in = new StringReader(out.toString())) {
Configuration configFromOut = new YamlConfigurationIo() //
.read(in) //
.build();
Assert.assertEquals(configFromFile, configFromOut);
}
}
示例2: ConfigurationService
import org.srcdeps.config.yaml.YamlConfigurationIo; //導入依賴的package包/類
@Inject
public ConfigurationService(@Named(SRCDEPS_YAML_PATH) Path srcdepsYamlPath) {
super();
this.configurationLocation = srcdepsYamlPath;
this.multimoduleProjectRootDirectory = srcdepsYamlPath.getParent();
final Configuration.Builder configBuilder;
if (Files.exists(srcdepsYamlPath)) {
log.debug("srcdeps: Using configuration {}", srcdepsYamlPath);
final String encoding = System.getProperty(Configuration.getSrcdepsEncodingProperty(), "utf-8");
final Charset cs = Charset.forName(encoding);
try (Reader r = Files.newBufferedReader(srcdepsYamlPath, cs)) {
configBuilder = new YamlConfigurationIo().read(r);
} catch (IOException | ConfigurationException e) {
throw new RuntimeException(e);
}
} else {
log.warn("srcdeps: Could not locate srcdeps configuration at {}, defaulting to an empty configuration",
srcdepsYamlPath);
configBuilder = Configuration.builder();
}
this.configuration = configBuilder //
.accept(new OverrideVisitor(System.getProperties())) //
.accept(new DefaultsAndInheritanceVisitor()) //
.build();
}
示例3: ConfigurationProducer
import org.srcdeps.config.yaml.YamlConfigurationIo; //導入依賴的package包/類
public ConfigurationProducer() {
super();
String basePathString = System.getProperty(Constants.MAVEN_MULTI_MODULE_PROJECT_DIRECTORY_PROPERTY);
if (basePathString == null || basePathString.isEmpty()) {
throw new RuntimeException(String.format("The system property %s must not be null or empty",
Constants.MAVEN_MULTI_MODULE_PROJECT_DIRECTORY_PROPERTY));
}
multimoduleProjectRootDirectory = Paths.get(basePathString).toAbsolutePath();
final Path defaultSrcdepsYamlPath = multimoduleProjectRootDirectory.resolve(SRCDEPS_YAML_PATH);
final Path legacySrcdepsYamlPath = multimoduleProjectRootDirectory.resolve(MVN_SRCDEPS_YAML_PATH);
Path srcdepsYamlPath = defaultSrcdepsYamlPath;
if (!Files.exists(srcdepsYamlPath)) {
srcdepsYamlPath = legacySrcdepsYamlPath;
}
this.configurationLocation = srcdepsYamlPath;
final Configuration.Builder configBuilder;
if (Files.exists(srcdepsYamlPath)) {
log.debug("SrcdepsLocalRepositoryManager using configuration {}", configurationLocation);
final String encoding = System.getProperty(Configuration.getSrcdepsEncodingProperty(), "utf-8");
final Charset cs = Charset.forName(encoding);
try (Reader r = Files.newBufferedReader(configurationLocation, cs)) {
configBuilder = new YamlConfigurationIo().read(r);
} catch (IOException | ConfigurationException e) {
throw new RuntimeException(e);
}
} else {
log.warn(
"Could not locate srcdeps configuration at neither {} nor {}, defaulting to an empty configuration",
defaultSrcdepsYamlPath, legacySrcdepsYamlPath);
configBuilder = Configuration.builder();
}
this.configuration = configBuilder //
.accept(new OverrideVisitor(System.getProperties())) //
.accept(new DefaultsAndInheritanceVisitor()) //
.build();
}