當前位置: 首頁>>代碼示例>>Java>>正文


Java PlainMigrationService類代碼示例

本文整理匯總了Java中ch.jalu.configme.migration.PlainMigrationService的典型用法代碼示例。如果您正苦於以下問題:Java PlainMigrationService類的具體用法?Java PlainMigrationService怎麽用?Java PlainMigrationService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PlainMigrationService類屬於ch.jalu.configme.migration包,在下文中一共展示了PlainMigrationService類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: generateUserInfo

import ch.jalu.configme.migration.PlainMigrationService; //導入依賴的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;
}
 
開發者ID:AuthMe,項目名稱:ConfigMe,代碼行數:18,代碼來源:BeanPropertiesDemo.java

示例2: shouldIncludeCommentFromAnnotation

import ch.jalu.configme.migration.PlainMigrationService; //導入依賴的package包/類
@Test
public void shouldIncludeCommentFromAnnotation() throws IOException {
    // given
    PropertyResource resource = new YamlFileResource(file);

    // when
    new SettingsManager(resource, new PlainMigrationService(), GroupPropertyHolder.class);

    // then
    assertThat(Files.readAllLines(file.toPath()), contains(
        "",
        "# Group configuration number",
        "default-gamemode: 'CREATIVE'",
        "worlds: ",
        "- 'world'"
    ));
}
 
開發者ID:AuthMe,項目名稱:ConfigMe,代碼行數:18,代碼來源:YamlFileResourceTopCommentTest.java

示例3: shouldIncludeRootCommentFromSectionCommentsMethod

import ch.jalu.configme.migration.PlainMigrationService; //導入依賴的package包/類
@Test
public void shouldIncludeRootCommentFromSectionCommentsMethod() throws IOException {
    // given
    PropertyResource resource = new YamlFileResource(file);

    // when
    new SettingsManager(resource, new PlainMigrationService(), TestConfig.class);

    // then
    assertThat(Files.readAllLines(file.toPath()), contains(
        "",
        "# Root comment",
        "# 'some' Section",
        "# Explanation for 'some'",
        "some:",
        "    # Integer property",
        "    test: 4",
        "    # Other header",
        "    other:",
        "        property: 'hello'"
    ));
}
 
開發者ID:AuthMe,項目名稱:ConfigMe,代碼行數:23,代碼來源:YamlFileResourceTopCommentTest.java

示例4: initSettings

import ch.jalu.configme.migration.PlainMigrationService; //導入依賴的package包/類
/**
 * Initializes the settings manager.
 *
 * @return the settings manager
 */
private SettingsManager initSettings() {
    // Copy the demo/config.yml instead of using it directly so it doesn't get overridden
    configFile = copyFileFromJar("/demo/config.yml");
    PropertyResource resource = new YamlFileResource(configFile);
    return new SettingsManager(resource, new PlainMigrationService(), TitleConfig.class);
}
 
開發者ID:AuthMe,項目名稱:ConfigMe,代碼行數:12,代碼來源:WelcomeWriter.java

示例5: Settings

import ch.jalu.configme.migration.PlainMigrationService; //導入依賴的package包/類
/**
 * Constructor.
 *
 * @param yamlFile the configuration file to load
 */
public Settings(File yamlFile) {
    super(
            new YamlFileResource(yamlFile),
            new PlainMigrationService(),
            PwiProperties.class);
}
 
開發者ID:Gnat008,項目名稱:PerWorldInventory,代碼行數:12,代碼來源:Settings.java

示例6: shouldLoadAndReadAllProperties

import ch.jalu.configme.migration.PlainMigrationService; //導入依賴的package包/類
@Test
public void shouldLoadAndReadAllProperties() throws IOException {
    // given
    PropertyResource resource = new YamlFileResource(copyFileFromResources(COMPLETE_FILE));
    // Pass another, non-existent file to check if the settings had to be rewritten
    File newFile = temporaryFolder.newFile();

    // when / then
    Settings settings = new Settings(testPluginFolder, resource,
        new PlainMigrationService(), CONFIG_DATA);
    Map<Property<?>, Object> expectedValues = ImmutableMap.<Property<?>, Object>builder()
        .put(TestConfiguration.DURATION_IN_SECONDS, 22)
        .put(TestConfiguration.SYSTEM_NAME, "Custom sys name")
        .put(TestConfiguration.RATIO_ORDER, TestEnum.FIRST)
        .put(TestConfiguration.RATIO_FIELDS, Arrays.asList("Australia", "Burundi", "Colombia"))
        .put(TestConfiguration.VERSION_NUMBER, 2492)
        .put(TestConfiguration.SKIP_BORING_FEATURES, false)
        .put(TestConfiguration.BORING_COLORS, Arrays.asList("beige", "gray"))
        .put(TestConfiguration.DUST_LEVEL, 2)
        .put(TestConfiguration.USE_COOL_FEATURES, true)
        .put(TestConfiguration.COOL_OPTIONS, Arrays.asList("Dinosaurs", "Explosions", "Big trucks"))
        .build();
    for (Map.Entry<Property<?>, Object> entry : expectedValues.entrySet()) {
        assertThat("Property '" + entry.getKey().getPath() + "' has expected value",
            settings.getProperty(entry.getKey()), equalTo(entry.getValue()));
    }
    assertThat(newFile.length(), equalTo(0L));
}
 
開發者ID:AuthMe,項目名稱:AuthMeReloaded,代碼行數:29,代碼來源:SettingsIntegrationTest.java

示例7: shouldProperlyExportAnyValues

import ch.jalu.configme.migration.PlainMigrationService; //導入依賴的package包/類
/** Verifies that "difficult cases" such as apostrophes in strings etc. are handled properly. */
@Test
public void shouldProperlyExportAnyValues() {
    // given
    File file = copyFileFromResources(DIFFICULT_FILE);
    YamlFileResource resource = new YamlFileResource(file);

    // Properties
    List<Property<?>> properties = new ArrayList<>(Arrays.asList(
        newProperty("more.string1", "it's a text with some \\'apostrophes'"),
        newProperty("more.string2", "\tthis one\nhas some\nnew '' lines-test")));
    properties.addAll(ConfigurationDataBuilder.collectData(TestConfiguration.class).getProperties());
    ConfigurationData configData = new ConfigurationData(properties);

    // when
    new SettingsManager(resource, new PlainMigrationService(), configData);
    // Save and load again
    resource.exportProperties(configData);
    resource.reload();

    // then
    assertThat(resource.getObject(TestConfiguration.DUST_LEVEL.getPath()), not(nullValue()));

    Map<Property<?>, Object> expected = new HashMap<>();
    expected.put(TestConfiguration.DURATION_IN_SECONDS, 20);
    expected.put(TestConfiguration.SYSTEM_NAME, "A 'test' name");
    expected.put(TestConfiguration.RATIO_ORDER, "FOURTH");
    expected.put(TestConfiguration.RATIO_FIELDS, Arrays.asList("Australia\\", "\tBurundi'", "Colombia?\n''"));
    expected.put(TestConfiguration.VERSION_NUMBER, -1337);
    expected.put(TestConfiguration.SKIP_BORING_FEATURES, false);
    expected.put(TestConfiguration.BORING_COLORS, Arrays.asList("it's a difficult string!", "gray\nwith new lines\n"));
    expected.put(TestConfiguration.DUST_LEVEL, -1);
    expected.put(TestConfiguration.USE_COOL_FEATURES, true);
    expected.put(TestConfiguration.COOL_OPTIONS, Collections.EMPTY_LIST);
    expected.put(properties.get(0), properties.get(0).getDefaultValue());
    expected.put(properties.get(1), properties.get(1).getDefaultValue());

    for (Map.Entry<Property<?>, Object> entry : expected.entrySet()) {
        assertThat("Property '" + entry.getKey().getPath() + "' has expected value",
            resource.getObject(entry.getKey().getPath()), equalTo(entry.getValue()));
    }
}
 
開發者ID:AuthMe,項目名稱:ConfigMe,代碼行數:43,代碼來源:YamlFileResourceTest.java

示例8: createWithYamlFile

import ch.jalu.configme.migration.PlainMigrationService; //導入依賴的package包/類
/**
 * Convenience method for creating a settings manager for the provided YAML file with defaults.
 * Creates the YAML file if it doesn't exist. Uses the default migration service, checking that all
 * properties are present in the YAML file.
 *
 * @param yamlFile the file to read from and write to
 * @param settingsClasses classes whose Property fields make up all known properties
 * @return the created settings manager
 */
@SafeVarargs
public static SettingsManager createWithYamlFile(File yamlFile,
                                                 Class<? extends SettingsHolder>... settingsClasses) {
    Utils.createFileIfNotExists(yamlFile);
    return new SettingsManager(new YamlFileResource(yamlFile), new PlainMigrationService(), settingsClasses);
}
 
開發者ID:AuthMe,項目名稱:ConfigMe,代碼行數:16,代碼來源:SettingsManager.java


注:本文中的ch.jalu.configme.migration.PlainMigrationService類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。