本文整理汇总了Java中ch.jalu.configme.configurationdata.ConfigurationDataBuilder.collectData方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationDataBuilder.collectData方法的具体用法?Java ConfigurationDataBuilder.collectData怎么用?Java ConfigurationDataBuilder.collectData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ch.jalu.configme.configurationdata.ConfigurationDataBuilder
的用法示例。
在下文中一共展示了ConfigurationDataBuilder.collectData方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateUserInfo
import ch.jalu.configme.configurationdata.ConfigurationDataBuilder; //导入方法依赖的package包/类
public String generateUserInfo() {
SettingsManager settingsManager = new SettingsManager(new YamlFileResource(configFile),
new PlainMigrationService(), ConfigurationDataBuilder.collectData(DemoSettings.class));
UserBase userBase = settingsManager.getProperty(DemoSettings.USER_BASE);
User richie = userBase.getRichie();
String savedLocationInfo = richie.getSavedLocations().entrySet().stream()
.map(entry -> entry.getKey() + " " + entry.getValue())
.collect(Collectors.joining(", "));
String info = "Saved locations of Richie: " + savedLocationInfo;
info += "\nNicknames of Bob: " + String.join(", ", userBase.getBobby().getNicknames());
Country country = settingsManager.getProperty(DemoSettings.COUNTRY);
info += "\nCountry '" + country.getName() + "' has neighbors: " + String.join(", ", country.getNeighbors());
return info;
}
示例2: shouldExportConfigurationWithExpectedComments
import ch.jalu.configme.configurationdata.ConfigurationDataBuilder; //导入方法依赖的package包/类
@Test
public void shouldExportConfigurationWithExpectedComments() throws IOException {
// given
File file = copyFileFromResources(COMPLETE_FILE);
PropertyResource resource = new YamlFileResource(file);
ConfigurationData configurationData = ConfigurationDataBuilder.collectData(TestConfiguration.class);
// when
resource.exportProperties(configurationData);
// then
// The IDE likes manipulating the whitespace in the expected file. As long as it's handled outside of an IDE
// this test should be fine.
assertThat(Files.readAllLines(file.toPath()),
equalTo(Files.readAllLines(getJarPath("/config-export-expected.yml"))));
}
示例3: shouldSetOptionalPropertyCorrectly
import ch.jalu.configme.configurationdata.ConfigurationDataBuilder; //导入方法依赖的package包/类
@Test
public void shouldSetOptionalPropertyCorrectly() {
// given
File file = copyFileFromResources("/config-sample.yml", temporaryFolder);
PropertyResource resource = new YamlFileResource(file);
SettingsManager settingsManager =
new SettingsManager(resource, null, ConfigurationDataBuilder.collectData(TestConfiguration.class));
OptionalProperty<Integer> intOptional = new OptionalProperty<>(newProperty("version", 65));
// assumption
assertThat(intOptional.getValue(resource), equalTo(Optional.of(2492)));
// when
settingsManager.setProperty(intOptional, Optional.empty());
// then
assertThat(intOptional.getValue(resource), equalTo(Optional.empty()));
// when (2)
settingsManager.setProperty(intOptional, Optional.of(43));
// then (2)
assertThat(intOptional.getValue(resource), equalTo(Optional.of(43)));
}
示例4: shouldWriteMissingProperties
import ch.jalu.configme.configurationdata.ConfigurationDataBuilder; //导入方法依赖的package包/类
@Test
public void shouldWriteMissingProperties() {
// given
File file = copyFileFromResources(INCOMPLETE_FILE);
YamlFileResource resource = new YamlFileResource(file);
ConfigurationData configurationData = ConfigurationDataBuilder.collectData(TestConfiguration.class);
// when
resource.exportProperties(configurationData);
// then
// Load file again to make sure what we wrote can be read again
resource = new YamlFileResource(file);
Map<Property<?>, Object> expected = new HashMap<>();
expected.put(TestConfiguration.DURATION_IN_SECONDS, 22);
expected.put(TestConfiguration.SYSTEM_NAME, "[TestDefaultValue]");
expected.put(TestConfiguration.RATIO_ORDER, "SECOND");
expected.put(TestConfiguration.RATIO_FIELDS, Arrays.asList("Australia", "Burundi", "Colombia"));
expected.put(TestConfiguration.VERSION_NUMBER, 32046);
expected.put(TestConfiguration.SKIP_BORING_FEATURES, false);
expected.put(TestConfiguration.BORING_COLORS, Collections.EMPTY_LIST);
expected.put(TestConfiguration.DUST_LEVEL, -1);
expected.put(TestConfiguration.USE_COOL_FEATURES, false);
expected.put(TestConfiguration.COOL_OPTIONS, Arrays.asList("Dinosaurs", "Explosions", "Big trucks"));
for (Map.Entry<Property<?>, Object> entry : expected.entrySet()) {
// Check with resource#getObject to make sure the values were persisted to the file
// If we go through Property objects they may fall back to their default values
String propertyPath = entry.getKey().getPath();
assertThat("Property '" + propertyPath + "' has expected value",
resource.getObject(propertyPath), equalTo(entry.getValue()));
}
}
示例5: buildConfigurationData
import ch.jalu.configme.configurationdata.ConfigurationDataBuilder; //导入方法依赖的package包/类
/**
* Builds the configuration data for all property fields in AuthMe {@link SettingsHolder} classes.
*
* @return configuration data
*/
public static ConfigurationData buildConfigurationData() {
return ConfigurationDataBuilder.collectData(
DatabaseSettings.class, PluginSettings.class, RestrictionSettings.class,
EmailSettings.class, HooksSettings.class, ProtectionSettings.class,
PurgeSettings.class, SecuritySettings.class, RegistrationSettings.class,
LimboSettings.class, BackupSettings.class, ConverterSettings.class);
}
示例6: SettingsManager
import ch.jalu.configme.configurationdata.ConfigurationDataBuilder; //导入方法依赖的package包/类
/**
* Constructor.
*
* @param resource the property resource to read and write properties to
* @param migrationService migration service to check the property resource with
* @param settingsClasses classes whose Property fields make up all known properties
*/
@SafeVarargs
public SettingsManager(PropertyResource resource, @Nullable MigrationService migrationService,
Class<? extends SettingsHolder>... settingsClasses) {
this(resource, migrationService, ConfigurationDataBuilder.collectData(settingsClasses));
}