@Test void fromPropertiesShouldReturnConfiguredValues() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.read(new StringReader( "jmx.address=172.0.0.5\n" + "jmx.port=889\n")); assertThat(JmxConfiguration.fromProperties(configuration)) .isEqualTo(new JmxConfiguration(JmxConfiguration.ENABLED, Optional.of(Host.from("172.0.0.5", 889)))); }
public static JmxConfiguration fromProperties(Configuration configuration) { boolean jmxEnabled = configuration.getBoolean("jmx.enabled", true); if (!jmxEnabled) { return DISABLED; } String address = configuration.getString("jmx.address", LOCALHOST); int port = configuration.getInt("jmx.port", DEFAULT_PORT); return new JmxConfiguration(ENABLED, Optional.of(Host.from(address, port))); }
JmxConfiguration { public static JmxConfiguration fromProperties(Configuration configuration) { boolean jmxEnabled = configuration.getBoolean("jmx.enabled", true); if (!jmxEnabled) { return DISABLED; } String address = configuration.getString("jmx.address", LOCALHOST); int port = configuration.getInt("jmx.port", DEFAULT_PORT); return new JmxConfiguration(ENABLED, Optional.of(Host.from(address, port))); } }
JmxConfiguration { public static JmxConfiguration fromProperties(Configuration configuration) { boolean jmxEnabled = configuration.getBoolean("jmx.enabled", true); if (!jmxEnabled) { return DISABLED; } String address = configuration.getString("jmx.address", LOCALHOST); int port = configuration.getInt("jmx.port", DEFAULT_PORT); return new JmxConfiguration(ENABLED, Optional.of(Host.from(address, port))); } @VisibleForTesting  JmxConfiguration(boolean enabled, Optional<Host> host); }
JmxConfiguration { public static JmxConfiguration fromProperties(Configuration configuration) { boolean jmxEnabled = configuration.getBoolean("jmx.enabled", true); if (!jmxEnabled) { return DISABLED; } String address = configuration.getString("jmx.address", LOCALHOST); int port = configuration.getInt("jmx.port", DEFAULT_PORT); return new JmxConfiguration(ENABLED, Optional.of(Host.from(address, port))); } @VisibleForTesting  JmxConfiguration(boolean enabled, Optional<Host> host); static JmxConfiguration fromProperties(Configuration configuration); boolean isEnabled(); Host getHost(); @Override final boolean equals(Object o); @Override final int hashCode(); @Override String toString(); }
JmxConfiguration { public static JmxConfiguration fromProperties(Configuration configuration) { boolean jmxEnabled = configuration.getBoolean("jmx.enabled", true); if (!jmxEnabled) { return DISABLED; } String address = configuration.getString("jmx.address", LOCALHOST); int port = configuration.getInt("jmx.port", DEFAULT_PORT); return new JmxConfiguration(ENABLED, Optional.of(Host.from(address, port))); } @VisibleForTesting  JmxConfiguration(boolean enabled, Optional<Host> host); static JmxConfiguration fromProperties(Configuration configuration); boolean isEnabled(); Host getHost(); @Override final boolean equals(Object o); @Override final int hashCode(); @Override String toString(); static final String LOCALHOST; static final int DEFAULT_PORT; static final boolean ENABLED; static final JmxConfiguration DEFAULT_CONFIGURATION; static final JmxConfiguration DISABLED; }