Java Code Examples for org.apache.commons.lang3.builder.ToStringBuilder#setDefaultStyle()
The following examples show how to use
org.apache.commons.lang3.builder.ToStringBuilder#setDefaultStyle() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SslContextFactory.java From nifi with Apache License 2.0 | 5 votes |
@Override public String toString() { final ToStringBuilder builder = new ToStringBuilder(this); ToStringBuilder.setDefaultStyle(ToStringStyle.SHORT_PREFIX_STYLE); builder.append("Type", type); builder.append("Description", description); return builder.toString(); }
Example 2
Source File: PeerStatusCache.java From nifi with Apache License 2.0 | 5 votes |
@Override public String toString() { final ToStringBuilder builder = new ToStringBuilder(this); ToStringBuilder.setDefaultStyle(ToStringStyle.SHORT_PREFIX_STYLE); builder.append("Timestamp", timestamp); builder.append("Transport protocol", transportProtocol); builder.append("Peer status count", statuses != null ? statuses.size() : 0); builder.append("Peer statuses", statuses); return builder.toString(); }
Example 3
Source File: StartupListener.java From jwala with Apache License 2.0 | 4 votes |
@Override public void contextInitialized(ServletContextEvent servletContextEvent) { ToStringBuilder.setDefaultStyle(ToStringStyle.SHORT_PREFIX_STYLE); DOMConfigurator.configure("../data/conf/log4j.xml"); }
Example 4
Source File: SerializationTest.java From Diorite with MIT License | 4 votes |
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()))); }
Example 5
Source File: ConfigTestNoSpecial.java From Diorite with MIT License | 4 votes |
@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(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()))); }
Example 6
Source File: ConfigTest.java From Diorite with MIT License | 4 votes |
@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); 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()))); }
Example 7
Source File: TypeSystemAnalysisTest.java From webanno with Apache License 2.0 | 4 votes |
@Before public void setup() { ToStringBuilder.setDefaultStyle(ToStringStyle.SHORT_PREFIX_STYLE); }