@Test public void testDelegationConfigurationWithNullPrefix() { Configuration backingConf = new Configuration(); backingConf.setValueInternal("test-key", "value"); DelegatingConfiguration configuration = new DelegatingConfiguration( backingConf, null); Set<String> keySet = configuration.keySet(); assertEquals(keySet, backingConf.keySet()); }
@Override public Set<String> keySet() { if (this.prefix == null) { return this.backingConfig.keySet(); } final HashSet<String> set = new HashSet<>(); int prefixLen = this.prefix.length(); for (String key : this.backingConfig.keySet()) { if (key.startsWith(prefix)) { set.add(key.substring(prefixLen)); } } return set; }
DelegatingConfiguration extends Configuration { @Override public Set<String> keySet() { if (this.prefix == null) { return this.backingConfig.keySet(); } final HashSet<String> set = new HashSet<>(); int prefixLen = this.prefix.length(); for (String key : this.backingConfig.keySet()) { if (key.startsWith(prefix)) { set.add(key.substring(prefixLen)); } } return set; } }
DelegatingConfiguration extends Configuration { @Override public Set<String> keySet() { if (this.prefix == null) { return this.backingConfig.keySet(); } final HashSet<String> set = new HashSet<>(); int prefixLen = this.prefix.length(); for (String key : this.backingConfig.keySet()) { if (key.startsWith(prefix)) { set.add(key.substring(prefixLen)); } } return set; } DelegatingConfiguration();  DelegatingConfiguration(Configuration backingConfig, String prefix); }
DelegatingConfiguration extends Configuration { @Override public Set<String> keySet() { if (this.prefix == null) { return this.backingConfig.keySet(); } final HashSet<String> set = new HashSet<>(); int prefixLen = this.prefix.length(); for (String key : this.backingConfig.keySet()) { if (key.startsWith(prefix)) { set.add(key.substring(prefixLen)); } } return set; } DelegatingConfiguration();  DelegatingConfiguration(Configuration backingConfig, String prefix); @Override String getString(String key, String defaultValue); @Override String getString(ConfigOption<String> configOption); @Override String getString(ConfigOption<String> configOption, String overrideDefault); @Override void setString(String key, String value); @Override void setString(ConfigOption<String> key, String value); @Override Class<T> getClass(String key, Class<? extends T> defaultValue, ClassLoader classLoader); @Override void setClass(String key, Class<?> klazz); @Override int getInteger(String key, int defaultValue); @Override int getInteger(ConfigOption<Integer> configOption); @Override int getInteger(ConfigOption<Integer> configOption, int overrideDefault); @Override void setInteger(String key, int value); @Override void setInteger(ConfigOption<Integer> key, int value); @Override long getLong(String key, long defaultValue); @Override long getLong(ConfigOption<Long> configOption); @Override long getLong(ConfigOption<Long> configOption, long overrideDefault); @Override void setLong(String key, long value); @Override void setLong(ConfigOption<Long> key, long value); @Override boolean getBoolean(String key, boolean defaultValue); @Override boolean getBoolean(ConfigOption<Boolean> configOption); @Override void setBoolean(String key, boolean value); @Override void setBoolean(ConfigOption<Boolean> key, boolean value); @Override boolean getBoolean(ConfigOption<Boolean> configOption, boolean overrideDefault); @Override float getFloat(String key, float defaultValue); @Override float getFloat(ConfigOption<Float> configOption); @Override float getFloat(ConfigOption<Float> configOption, float overrideDefault); @Override void setFloat(String key, float value); @Override void setFloat(ConfigOption<Float> key, float value); @Override double getDouble(String key, double defaultValue); @Override double getDouble(ConfigOption<Double> configOption); @Override double getDouble(ConfigOption<Double> configOption, double overrideDefault); @Override void setDouble(String key, double value); @Override void setDouble(ConfigOption<Double> key, double value); @Override byte[] getBytes(final String key, final byte[] defaultValue); @Override void setBytes(final String key, final byte[] bytes); @Override String getValue(ConfigOption<?> configOption); @Override T getEnum(final Class<T> enumClass, final ConfigOption<String> configOption); @Override void addAllToProperties(Properties props); @Override void addAll(Configuration other); @Override void addAll(Configuration other, String prefix); @Override String toString(); @Override Set<String> keySet(); @Override Configuration clone(); @Override Map<String, String> toMap(); @Override boolean removeConfig(ConfigOption<T> configOption); @Override boolean containsKey(String key); @Override boolean contains(ConfigOption<?> configOption); @Override void read(DataInputView in); @Override void write(DataOutputView out); @Override int hashCode(); @Override boolean equals(Object obj); }
DelegatingConfiguration extends Configuration { @Override public Set<String> keySet() { if (this.prefix == null) { return this.backingConfig.keySet(); } final HashSet<String> set = new HashSet<>(); int prefixLen = this.prefix.length(); for (String key : this.backingConfig.keySet()) { if (key.startsWith(prefix)) { set.add(key.substring(prefixLen)); } } return set; } DelegatingConfiguration();  DelegatingConfiguration(Configuration backingConfig, String prefix); @Override String getString(String key, String defaultValue); @Override String getString(ConfigOption<String> configOption); @Override String getString(ConfigOption<String> configOption, String overrideDefault); @Override void setString(String key, String value); @Override void setString(ConfigOption<String> key, String value); @Override Class<T> getClass(String key, Class<? extends T> defaultValue, ClassLoader classLoader); @Override void setClass(String key, Class<?> klazz); @Override int getInteger(String key, int defaultValue); @Override int getInteger(ConfigOption<Integer> configOption); @Override int getInteger(ConfigOption<Integer> configOption, int overrideDefault); @Override void setInteger(String key, int value); @Override void setInteger(ConfigOption<Integer> key, int value); @Override long getLong(String key, long defaultValue); @Override long getLong(ConfigOption<Long> configOption); @Override long getLong(ConfigOption<Long> configOption, long overrideDefault); @Override void setLong(String key, long value); @Override void setLong(ConfigOption<Long> key, long value); @Override boolean getBoolean(String key, boolean defaultValue); @Override boolean getBoolean(ConfigOption<Boolean> configOption); @Override void setBoolean(String key, boolean value); @Override void setBoolean(ConfigOption<Boolean> key, boolean value); @Override boolean getBoolean(ConfigOption<Boolean> configOption, boolean overrideDefault); @Override float getFloat(String key, float defaultValue); @Override float getFloat(ConfigOption<Float> configOption); @Override float getFloat(ConfigOption<Float> configOption, float overrideDefault); @Override void setFloat(String key, float value); @Override void setFloat(ConfigOption<Float> key, float value); @Override double getDouble(String key, double defaultValue); @Override double getDouble(ConfigOption<Double> configOption); @Override double getDouble(ConfigOption<Double> configOption, double overrideDefault); @Override void setDouble(String key, double value); @Override void setDouble(ConfigOption<Double> key, double value); @Override byte[] getBytes(final String key, final byte[] defaultValue); @Override void setBytes(final String key, final byte[] bytes); @Override String getValue(ConfigOption<?> configOption); @Override T getEnum(final Class<T> enumClass, final ConfigOption<String> configOption); @Override void addAllToProperties(Properties props); @Override void addAll(Configuration other); @Override void addAll(Configuration other, String prefix); @Override String toString(); @Override Set<String> keySet(); @Override Configuration clone(); @Override Map<String, String> toMap(); @Override boolean removeConfig(ConfigOption<T> configOption); @Override boolean containsKey(String key); @Override boolean contains(ConfigOption<?> configOption); @Override void read(DataInputView in); @Override void write(DataOutputView out); @Override int hashCode(); @Override boolean equals(Object obj);  }