dbflute / dbflute-core

DBFlute core libraries for Java8
http://dbflute.seasar.org/
23 stars 18 forks source link

DBFlute Engine: FreeGen, fix overrideMap boolean handling #139

Closed jflute closed 2 years ago

jflute commented 2 years ago

needs to convert to e.g. "true" to true for template use like this:

protected <VALUE> VALUE filterOverridden(VALUE standardValue, Map<String, Object> lastafluteMap, String appName, String title,
        String key) {
    // e.g. lastafluteMap.dfprop
    //  ; overrideMap = map:{
    //      ; hangar.freeGen.appcls.isSuppressRedundantCommentStop = true
    //  }
    final VALUE overridingValue = extractOverridingValue(lastafluteMap, appName, title, key);
    if (overridingValue != null) {
        if (standardValue instanceof Boolean) {
            // convert to e.g. "true" to true for template use
            final Boolean nativeBoolean = "true".equalsIgnoreCase(overridingValue.toString());
            @SuppressWarnings("unchecked")
            final VALUE typeMatched = (VALUE) nativeBoolean;
            return typeMatched;
        } else {
            return overridingValue;
        }
    } else {
        return standardValue;
    }
}