当前位置: 首页>>代码示例>>Java>>正文


Java ToStringBuilder.setDefaultStyle方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.builder.ToStringBuilder.setDefaultStyle方法的典型用法代码示例。如果您正苦于以下问题:Java ToStringBuilder.setDefaultStyle方法的具体用法?Java ToStringBuilder.setDefaultStyle怎么用?Java ToStringBuilder.setDefaultStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.builder.ToStringBuilder的用法示例。


在下文中一共展示了ToStringBuilder.setDefaultStyle方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testTypes

import org.apache.commons.lang3.builder.ToStringBuilder; //导入方法依赖的package包/类
@Test
public void testTypes() throws Exception
{
    SerializationTest.prepareSerialization();
    ToStringBuilder.setDefaultStyle(ToStringStyle.SHORT_PREFIX_STYLE);

    ConfigTemplate<TypeTestConfig> configTemplate = this.configManager.getConfigFile(TypeTestConfig.class);
    Assert.assertNotNull(configTemplate);
    Assert.assertEquals(TypeTestConfig.class.getSimpleName(), configTemplate.getName());
    Assert.assertEquals(StandardCharsets.UTF_8, configTemplate.getDefaultDecoder().charset());
    Assert.assertEquals(StandardCharsets.UTF_8, configTemplate.getDefaultEncoder().charset());

    System.out.println("[ConfigTypeTest] creating config instance.");
    TypeTestConfig cfg = configTemplate.create();
    Assert.assertNotNull(cfg);

    Assert.assertSame(1, cfg.getCopyTest()[0]);
    cfg.getCopyTest()[0] = 2;
    Assert.assertSame(1, cfg.getCopyTest()[0]);

    Assert.assertSame(1, cfg.getNonCopyTest()[0]);
    cfg.getNonCopyTest()[0] = 2;
    Assert.assertSame(2, cfg.getNonCopyTest()[0]);

    cfg.save(System.out);
    // check if all data is still valid after reload of config.
    StringBuilderWriter writer = new StringBuilderWriter(500);
    cfg.save(writer);
    Files.write(new File("target/yaml-test-file.yml").toPath(), writer.toString().getBytes(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
    TypeTestConfig cfgCopy = configTemplate.create();
    cfg.forEach(cfgCopy::set);
    cfgCopy.bindFile(new File("target/yaml-test-file.yml"));
    cfgCopy.save();
    cfgCopy.load();
    cfgCopy.save();
    cfgCopy.load();
    cfgCopy.bindFile(null);
    Assert.assertEquals(cfg, cfgCopy);
}
 
开发者ID:GotoFinal,项目名称:diorite-configs-java8,代码行数:40,代码来源:ConfigTest.java

示例2: contextInitialized

import org.apache.commons.lang3.builder.ToStringBuilder; //导入方法依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
    ToStringBuilder.setDefaultStyle(ToStringStyle.SHORT_PREFIX_STYLE);

    DOMConfigurator.configure("../data/conf/log4j.xml");
}
 
开发者ID:cerner,项目名称:jwala,代码行数:7,代码来源:StartupListener.java

示例3: test

import org.apache.commons.lang3.builder.ToStringBuilder; //导入方法依赖的package包/类
public void test() throws Exception
    {
        SerializationTest.prepareSerialization();
        ToStringBuilder.setDefaultStyle(ToStringStyle.SHORT_PREFIX_STYLE);


        ConfigTemplate<SomeConfig> configTemplate = this.configManager.getConfigFile(SomeConfig.class);
        Assert.assertNotNull(configTemplate);
        Assert.assertEquals(SomeConfig.class.getSimpleName(), configTemplate.getName());
        Assert.assertEquals(StandardCharsets.UTF_8, configTemplate.getDefaultDecoder().charset());
        Assert.assertEquals(StandardCharsets.UTF_8, configTemplate.getDefaultEncoder().charset());

        System.out.println("[ConfigTest] creating config instance.");
        SomeConfig someConfig = configTemplate.create();
        Assert.assertNotNull(someConfig);
//
        this.testNicknames(someConfig);
        Assert.assertNotNull(someConfig.getSpecialData());
        someConfig.setStorage(SerializationTest.prepareObject());
//
        someConfig.save(System.out);
//
//        try
//        {
//            someConfig.getSpecialData().clear();
//            Assert.assertTrue("This should never happen, special data should be immutable.", false);
//        }
//        catch (UnsupportedOperationException e)
//        {
//        }
//        MetaObject snowflake = new MetaObject("snowflake", new MetaValue("so special", 25));
//        someConfig.putInSpecialData(snowflake);
//        Assert.assertEquals(List.of(snowflake), someConfig.getSpecialData());
//
//        UUID randomUUID = UUID.randomUUID();
//        someConfig.putInEvenMoreSpecialData(randomUUID, snowflake);
//        Assert.assertEquals(1, someConfig.getEvenMoreSpecialData().size());
//
//        System.out.println("\n====================\n");
//        someConfig.save(System.out);
//
//        Assert.assertEquals(snowflake, someConfig.removeFromEvenMoreSpecialData(randomUUID));
//        Assert.assertTrue(someConfig.getEvenMoreSpecialData().isEmpty());
//
//
//        // check if all data is still valid after reload of config.
//        StringBuilderWriter writer = new StringBuilderWriter(500);
//        someConfig.save(writer);
//        Assert.assertEquals(someConfig, configTemplate.load(new StringReader(writer.toString())));
    }
 
开发者ID:GotoFinal,项目名称:diorite-configs-java8,代码行数:51,代码来源:SerializationTest.java

示例4: test

import org.apache.commons.lang3.builder.ToStringBuilder; //导入方法依赖的package包/类
@Test
public void test() throws Exception
{
    SerializationTest.prepareSerialization();
    ToStringBuilder.setDefaultStyle(ToStringStyle.SHORT_PREFIX_STYLE);


    ConfigTemplate<SomeConfigNoSpecial> configTemplate = this.configManager.getConfigFile(SomeConfigNoSpecial.class);
    Assert.assertNotNull(configTemplate);
    Assert.assertEquals(SomeConfigNoSpecial.class.getSimpleName(), configTemplate.getName());
    Assert.assertEquals(StandardCharsets.UTF_8, configTemplate.getDefaultDecoder().charset());
    Assert.assertEquals(StandardCharsets.UTF_8, configTemplate.getDefaultEncoder().charset());

    System.out.println("[ConfigTest] creating config instance.");
    SomeConfigNoSpecial someConfig = configTemplate.create();
    Assert.assertNotNull(someConfig);

    this.testNicknames(someConfig);
    Assert.assertNotNull(someConfig.getSpecialData());
    someConfig.setStorage(SerializationTest.prepareObject());

    someConfig.save(System.out);

    try
    {
        someConfig.getSpecialData().clear();
        Assert.assertTrue("This should never happen, special data should be immutable.", false);
    }
    catch (UnsupportedOperationException e)
    {
    }
    MetaObject snowflake = new MetaObject("snowflake", new MetaValue("so special", 25));
    someConfig.putInSpecialData(snowflake);
    Assert.assertEquals(ImmutableList.of(snowflake), someConfig.getSpecialData());

    UUID randomUUID = UUID.randomUUID();
    someConfig.putInEvenMoreSpecialData(randomUUID, snowflake);
    Assert.assertEquals(1, someConfig.getEvenMoreSpecialData().size());

    System.out.println("\n====================\n");
    someConfig.save(System.out);

    Assert.assertEquals(snowflake, someConfig.removeFromEvenMoreSpecialData(randomUUID));
    Assert.assertTrue(someConfig.getEvenMoreSpecialData().isEmpty());


    // check if all data is still valid after reload of config.
    StringBuilderWriter writer = new StringBuilderWriter(500);
    someConfig.save(writer);
    Assert.assertEquals(someConfig, configTemplate.load(new StringReader(writer.toString())));
}
 
开发者ID:GotoFinal,项目名称:diorite-configs-java8,代码行数:52,代码来源:ConfigTestNoSpecial.java

示例5: test

import org.apache.commons.lang3.builder.ToStringBuilder; //导入方法依赖的package包/类
@Test
public void test() throws Exception
{
    SerializationTest.prepareSerialization();
    ToStringBuilder.setDefaultStyle(ToStringStyle.SHORT_PREFIX_STYLE);


    ConfigTemplate<SomeConfig> configTemplate = this.configManager.getConfigFile(SomeConfig.class);
    Assert.assertNotNull(configTemplate);
    Assert.assertEquals(SomeConfig.class.getSimpleName(), configTemplate.getName());
    Assert.assertEquals(StandardCharsets.UTF_8, configTemplate.getDefaultDecoder().charset());
    Assert.assertEquals(StandardCharsets.UTF_8, configTemplate.getDefaultEncoder().charset());

    System.out.println("[ConfigTest] creating config instance.");
    SomeConfig someConfig = configTemplate.create();
    Assert.assertNotNull(someConfig);

    Assert.assertNull(someConfig.metadata().get("meta"));
    Assert.assertEquals("1", someConfig.getSomething());
    Assert.assertNull(someConfig.get("something"));
    Assert.assertEquals("meta value", someConfig.metadata().get("meta"));

    Assert.assertNotNull(someConfig.getEnumValue());
    someConfig.setEnumValue(TestEnum.C);
    Assert.assertSame(TestEnum.C, someConfig.getEnumValue());
    this.testNicknames(someConfig);
    Assert.assertNotNull(someConfig.getSpecialData());
    someConfig.setStorage(SerializationTest.prepareObject());

    someConfig.save(System.out);

    try
    {
        someConfig.getSpecialData().clear();
        Assert.assertTrue("This should never happen, special data should be immutable.", false);
    }
    catch (UnsupportedOperationException e)
    {
    }
    MetaObject snowflake = new MetaObject("snowflake", new MetaValue("so special", 25));
    someConfig.putInSpecialData(snowflake);
    Assert.assertEquals(ImmutableList.of(snowflake), someConfig.getSpecialData());

    UUID randomUUID = UUID.randomUUID();
    someConfig.putInEvenMoreSpecialData(randomUUID, snowflake);
    Assert.assertEquals(1, someConfig.getEvenMoreSpecialData().size());

    System.out.println("\n====================\n");
    someConfig.save(System.out);

    Assert.assertEquals(snowflake, someConfig.removeFromEvenMoreSpecialData(randomUUID));
    Assert.assertTrue(someConfig.getEvenMoreSpecialData().isEmpty());
    someConfig.putInEvenMoreSpecialData(randomUUID, snowflake);
    Assert.assertEquals(1, someConfig.getEvenMoreSpecialData().size());

    Assert.assertTrue(someConfig.removeFromEvenMoreSpecialDataIf((key, value) -> key.equals(randomUUID)));
    Assert.assertTrue(someConfig.getEvenMoreSpecialData().isEmpty());
    someConfig.putInEvenMoreSpecialData(randomUUID, snowflake);
    Assert.assertEquals(1, someConfig.getEvenMoreSpecialData().size());

    Assert.assertTrue(someConfig.removeFromEvenMoreSpecialDataIf((key, value) -> value.equals(snowflake)));
    Assert.assertTrue(someConfig.getEvenMoreSpecialData().isEmpty());
    someConfig.putInEvenMoreSpecialData(randomUUID, snowflake);
    Assert.assertEquals(1, someConfig.getEvenMoreSpecialData().size());

    Assert.assertTrue(someConfig.removeFromEvenMoreSpecialDataIf((entry) -> entry.getValue().equals(snowflake)));
    Assert.assertTrue(someConfig.getEvenMoreSpecialData().isEmpty());
    someConfig.putInEvenMoreSpecialData(randomUUID, snowflake);
    Assert.assertEquals(1, someConfig.getEvenMoreSpecialData().size());

    someConfig.putInEvenMoreSpecialData(randomUUID, snowflake);
    Assert.assertEquals(1, someConfig.getEvenMoreSpecialData().size());


    // check if all data is still valid after reload of config.
    StringBuilderWriter writer = new StringBuilderWriter(500);
    someConfig.save(writer);
    Assert.assertEquals(someConfig, configTemplate.load(new StringReader(writer.toString())));
}
 
开发者ID:GotoFinal,项目名称:diorite-configs-java8,代码行数:80,代码来源:ConfigTest.java


注:本文中的org.apache.commons.lang3.builder.ToStringBuilder.setDefaultStyle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。