@@ -120,10 +120,18 @@ public String toString() {
120120
121121 static ConfigDepotImpl s_depot = null ;
122122
123- static public void init (ConfigDepotImpl depot ) {
123+ private String _defaultValueIfEmpty = null ;
124+
125+ public static void init (ConfigDepotImpl depot ) {
124126 s_depot = depot ;
125127 }
126128
129+ public ConfigKey (Class <T > type , String name , String category , String defaultValue , String description , boolean isDynamic , Scope scope , T multiplier ,
130+ String displayText , String parent , Ternary <String , String , Long > group , Pair <String , Long > subGroup , Kind kind , String options , String defaultValueIfEmpty ) {
131+ this (type , name , category , defaultValue , description , isDynamic , scope , multiplier , displayText , parent , group , subGroup , kind , options );
132+ this ._defaultValueIfEmpty = defaultValueIfEmpty ;
133+ }
134+
127135 public ConfigKey (String category , Class <T > type , String name , String defaultValue , String description , boolean isDynamic , Scope scope ) {
128136 this (type , name , category , defaultValue , description , isDynamic , scope , null );
129137 }
@@ -216,7 +224,19 @@ public boolean isSameKeyAs(Object obj) {
216224 public T value () {
217225 if (_value == null || isDynamic ()) {
218226 String value = s_depot != null ? s_depot .getConfigStringValue (_name , Scope .Global , null ) : null ;
219- _value = valueOf ((value == null ) ? defaultValue () : value );
227+
228+ String effective ;
229+ if (value != null ) {
230+ if (value .isEmpty () && _defaultValueIfEmpty != null ) {
231+ effective = _defaultValueIfEmpty ;
232+ } else {
233+ effective = value ;
234+ }
235+ } else {
236+ effective = _defaultValueIfEmpty != null ? _defaultValueIfEmpty : defaultValue ();
237+ }
238+
239+ _value = valueOf (effective );
220240 }
221241
222242 return _value ;
@@ -231,6 +251,10 @@ protected T valueInScope(Scope scope, Long id) {
231251 if (value == null ) {
232252 return value ();
233253 }
254+
255+ if (value .isEmpty () && _defaultValueIfEmpty != null ) {
256+ return valueOf (_defaultValueIfEmpty );
257+ }
234258 return valueOf (value );
235259 }
236260
0 commit comments