@@ -267,10 +267,18 @@ public String toString() {
267267
268268 static ConfigDepotImpl s_depot = null ;
269269
270- static public void init (ConfigDepotImpl depot ) {
270+ private String _defaultValueIfEmpty = null ;
271+
272+ public static void init (ConfigDepotImpl depot ) {
271273 s_depot = depot ;
272274 }
273275
276+ public ConfigKey (Class <T > type , String name , String category , String defaultValue , String description , boolean isDynamic , List <Scope > scopes , T multiplier ,
277+ String displayText , String parent , Ternary <String , String , Long > group , Pair <String , Long > subGroup , Kind kind , String options , String defaultValueIfEmpty ) {
278+ this (type , name , category , defaultValue , description , isDynamic , scopes , multiplier , displayText , parent , group , subGroup , kind , options );
279+ this ._defaultValueIfEmpty = defaultValueIfEmpty ;
280+ }
281+
274282 public ConfigKey (String category , Class <T > type , String name , String defaultValue , String description , boolean isDynamic , Scope scope ) {
275283 this (type , name , category , defaultValue , description , isDynamic , scope , null );
276284 }
@@ -380,7 +388,19 @@ public boolean isSameKeyAs(Object obj) {
380388 public T value () {
381389 if (_value == null || isDynamic ()) {
382390 String value = s_depot != null ? s_depot .getConfigStringValue (_name , Scope .Global , null ) : null ;
383- _value = valueOf ((value == null ) ? defaultValue () : value );
391+
392+ String effective ;
393+ if (value != null ) {
394+ if (value .isEmpty () && _defaultValueIfEmpty != null ) {
395+ effective = _defaultValueIfEmpty ;
396+ } else {
397+ effective = value ;
398+ }
399+ } else {
400+ effective = _defaultValueIfEmpty != null ? _defaultValueIfEmpty : defaultValue ();
401+ }
402+
403+ _value = valueOf (effective );
384404 }
385405 return _value ;
386406 }
@@ -409,6 +429,9 @@ public T valueInScope(Scope scope, Long id) {
409429 return valueInGlobalOrAvailableParentScope (scope , id );
410430 }
411431 logger .trace ("Scope({}) value for config ({}): {}" , scope , _name , _value );
432+ if (value .isEmpty () && _defaultValueIfEmpty != null ) {
433+ return valueOf (_defaultValueIfEmpty );
434+ }
412435 return valueOf (value );
413436 }
414437
0 commit comments