Initial Commit
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package net.locusworks.common.properties;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
public class ImmutableProperties extends Properties {
|
||||
|
||||
private static final long serialVersionUID = 65942088008978137L;
|
||||
|
||||
public ImmutableProperties() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ImmutableProperties(Properties props) {
|
||||
super();
|
||||
if (props == null || props.isEmpty()) return;
|
||||
|
||||
props.entrySet().forEach(item -> this.put(item.getKey(), item.getValue()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Object setProperty(String key, String value) {
|
||||
return put(key, value);
|
||||
}
|
||||
|
||||
public synchronized Object put(Object key, Object value) {
|
||||
if (containsKey(key))
|
||||
throw new RuntimeException("Cannot change key value once its set: " + key);
|
||||
return super.put(key, value);
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user