mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-14 23:36:27 -04:00
simplified the key
This commit is contained in:
parent
61433b274c
commit
c5af6bfeb5
@ -16,7 +16,6 @@ import java.io.File;
|
|||||||
*/
|
*/
|
||||||
public class Key<VALUE> {
|
public class Key<VALUE> {
|
||||||
private final String key;
|
private final String key;
|
||||||
private final VALUE def;
|
|
||||||
private final DefaultFactory<VALUE> defFactory;
|
private final DefaultFactory<VALUE> defFactory;
|
||||||
private final String langKey;
|
private final String langKey;
|
||||||
private boolean groupEditAllowed = false;
|
private boolean groupEditAllowed = false;
|
||||||
@ -38,12 +37,9 @@ public class Key<VALUE> {
|
|||||||
* @param def the default value
|
* @param def the default value
|
||||||
*/
|
*/
|
||||||
public Key(String key, VALUE def) {
|
public Key(String key, VALUE def) {
|
||||||
this.key = key;
|
this(key, () -> def);
|
||||||
langKey = "key_" + key.replace(" ", "");
|
|
||||||
if (def == null)
|
if (def == null)
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
this.def = def;
|
|
||||||
this.defFactory = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,7 +54,6 @@ public class Key<VALUE> {
|
|||||||
langKey = "key_" + key.replace(" ", "");
|
langKey = "key_" + key.replace(" ", "");
|
||||||
if (defFactory == null)
|
if (defFactory == null)
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
this.def = null;
|
|
||||||
this.defFactory = defFactory;
|
this.defFactory = defFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,10 +82,7 @@ public class Key<VALUE> {
|
|||||||
* @return the default value of this key
|
* @return the default value of this key
|
||||||
*/
|
*/
|
||||||
public VALUE getDefault() {
|
public VALUE getDefault() {
|
||||||
if (def != null)
|
return defFactory.createDefault();
|
||||||
return def;
|
|
||||||
else
|
|
||||||
return defFactory.createDefault();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user