@Test public void testRemovePropsWithPrefix() { final State state = new State(); final String prefix = "prefix"; for (int i = 0; i < 10; i++) { state.setProp("prefix." + i, i); } Assert.assertTrue(state.getPropertyNames().size() == 10); state.removePropsWithPrefix(prefix); Assert.assertTrue(state.getPropertyNames().size() == 0); }
public void removePropsWithPrefix(String prefix) { this.specProperties.entrySet().removeIf(entry -> ((String) entry.getKey()).startsWith(prefix)); Properties newCommonProperties = null; for (Object key: this.commonProperties.keySet()) { if (((String)key).startsWith(prefix)) { if (newCommonProperties == null) { newCommonProperties = new Properties(); newCommonProperties.putAll(this.commonProperties); } newCommonProperties.remove(key); } } if (newCommonProperties != null) { this.commonProperties = newCommonProperties; } }
State implements WritableShim { public void removePropsWithPrefix(String prefix) { this.specProperties.entrySet().removeIf(entry -> ((String) entry.getKey()).startsWith(prefix)); Properties newCommonProperties = null; for (Object key: this.commonProperties.keySet()) { if (((String)key).startsWith(prefix)) { if (newCommonProperties == null) { newCommonProperties = new Properties(); newCommonProperties.putAll(this.commonProperties); } newCommonProperties.remove(key); } } if (newCommonProperties != null) { this.commonProperties = newCommonProperties; } } }
State implements WritableShim { public void removePropsWithPrefix(String prefix) { this.specProperties.entrySet().removeIf(entry -> ((String) entry.getKey()).startsWith(prefix)); Properties newCommonProperties = null; for (Object key: this.commonProperties.keySet()) { if (((String)key).startsWith(prefix)) { if (newCommonProperties == null) { newCommonProperties = new Properties(); newCommonProperties.putAll(this.commonProperties); } newCommonProperties.remove(key); } } if (newCommonProperties != null) { this.commonProperties = newCommonProperties; } } State();  State(Properties properties);  State(State otherState); }
State implements WritableShim { public void removePropsWithPrefix(String prefix) { this.specProperties.entrySet().removeIf(entry -> ((String) entry.getKey()).startsWith(prefix)); Properties newCommonProperties = null; for (Object key: this.commonProperties.keySet()) { if (((String)key).startsWith(prefix)) { if (newCommonProperties == null) { newCommonProperties = new Properties(); newCommonProperties.putAll(this.commonProperties); } newCommonProperties.remove(key); } } if (newCommonProperties != null) { this.commonProperties = newCommonProperties; } } State();  State(Properties properties);  State(State otherState); Properties getProperties(); void addAll(State otherState); void addAll(Properties properties); void addAllIfNotExist(State otherState); void addAllIfNotExist(Properties properties); void overrideWith(State otherState); void overrideWith(Properties properties); void setId(String id); String getId(); void setProp(String key, Object value); void setProps(Properties commonProperties, Properties specProperties); synchronized void appendToListProp(String key, String value); synchronized void appendToSetProp(String key, String value); String getProp(String key); String getProp(String key, String def); List<String> getPropAsList(String key); List<String> getPropAsList(String key, String def); Set<String> getPropAsSet(String key); Set<String> getPropAsSet(String key, String def); Set<String> getPropAsCaseInsensitiveSet(String key); Set<String> getPropAsCaseInsensitiveSet(String key, String def); long getPropAsLong(String key); long getPropAsLong(String key, long def); int getPropAsInt(String key); int getPropAsInt(String key, int def); short getPropAsShort(String key); short getPropAsShortWithRadix(String key, int radix); short getPropAsShort(String key, short def); short getPropAsShortWithRadix(String key, short def, int radix); double getPropAsDouble(String key); double getPropAsDouble(String key, double def); boolean getPropAsBoolean(String key); boolean getPropAsBoolean(String key, boolean def); JsonArray getPropAsJsonArray(String key); void removeProp(String key); void removePropsWithPrefix(String prefix); Set<String> getPropertyNames(); boolean contains(String key); @Override void readFields(DataInput in); @Override void write(DataOutput out); @Override String toString(); }
State implements WritableShim { public void removePropsWithPrefix(String prefix) { this.specProperties.entrySet().removeIf(entry -> ((String) entry.getKey()).startsWith(prefix)); Properties newCommonProperties = null; for (Object key: this.commonProperties.keySet()) { if (((String)key).startsWith(prefix)) { if (newCommonProperties == null) { newCommonProperties = new Properties(); newCommonProperties.putAll(this.commonProperties); } newCommonProperties.remove(key); } } if (newCommonProperties != null) { this.commonProperties = newCommonProperties; } } State();  State(Properties properties);  State(State otherState); Properties getProperties(); void addAll(State otherState); void addAll(Properties properties); void addAllIfNotExist(State otherState); void addAllIfNotExist(Properties properties); void overrideWith(State otherState); void overrideWith(Properties properties); void setId(String id); String getId(); void setProp(String key, Object value); void setProps(Properties commonProperties, Properties specProperties); synchronized void appendToListProp(String key, String value); synchronized void appendToSetProp(String key, String value); String getProp(String key); String getProp(String key, String def); List<String> getPropAsList(String key); List<String> getPropAsList(String key, String def); Set<String> getPropAsSet(String key); Set<String> getPropAsSet(String key, String def); Set<String> getPropAsCaseInsensitiveSet(String key); Set<String> getPropAsCaseInsensitiveSet(String key, String def); long getPropAsLong(String key); long getPropAsLong(String key, long def); int getPropAsInt(String key); int getPropAsInt(String key, int def); short getPropAsShort(String key); short getPropAsShortWithRadix(String key, int radix); short getPropAsShort(String key, short def); short getPropAsShortWithRadix(String key, short def, int radix); double getPropAsDouble(String key); double getPropAsDouble(String key, double def); boolean getPropAsBoolean(String key); boolean getPropAsBoolean(String key, boolean def); JsonArray getPropAsJsonArray(String key); void removeProp(String key); void removePropsWithPrefix(String prefix); Set<String> getPropertyNames(); boolean contains(String key); @Override void readFields(DataInput in); @Override void write(DataOutput out); @Override String toString();  }