private static Object getValue(String content) {
        InjectionPattern injectionPattern = getInjectionPattern(content);
        Object value = null;
        if (injectionPattern != null) {
            // Use key of injectionPattern to get value from both environment variables and "values.yaml"
            Object envValue = typeCast(System.getenv(injectionPattern.getKey()));
            Map<String, Object> valueMap = Config.getInstance().getJsonMapConfig(CENTRALIZED_MANAGEMENT);
            Object fileValue = (valueMap != null) ? valueMap.get(injectionPattern.getKey()) : null;
            // Return different value from different sources based on injection order defined before
            if ((INJECTION_ORDER_CODE.equals("2") && envValue != null) || (INJECTION_ORDER_CODE.equals("1") && fileValue == null)) {
                value = envValue;
            } else {
                value = fileValue;
            }
            // Return default value when no matched value found from environment variables and "values.yaml"
            if (value == null || value.equals("")) {
                value = typeCast(injectionPattern.getDefaultValue());
                // Throw exception when error text provided
                if (value == null || value.equals("")) {
                    String error_text = injectionPattern.getErrorText();
                    if (error_text != null && !error_text.equals("")) {
                        throw new ConfigException(error_text);
                    }
                }
            }
            // Throw exception when no parsing result found
            if (value == null && valueMap != null && !valueMap.containsKey(injectionPattern.getKey())) {
                throw new ConfigException("\"${" + content + "}\" appears in config file cannot be expanded");
            }
        }
        return value;
    }
private static Object getValue ( String content ) { InjectionPattern injectionPattern = getInjectionPattern ( content ) ; Object value = null ; if ( injectionPattern != null ) { Object envValue = typeCast ( System . getenv ( injectionPattern . getKey ( ) ) ) ; Map < String , Object > valueMap = Config . getInstance ( ) . getJsonMapConfig ( CENTRALIZED_MANAGEMENT ) ; Object fileValue = ( valueMap != null ) ? valueMap . get ( injectionPattern . getKey ( ) ) : null ; if ( ( INJECTION_ORDER_CODE . equals ( "2" ) && envValue != null ) || ( INJECTION_ORDER_CODE . equals ( "1" ) && fileValue == null ) ) { value = envValue ; } else { value = fileValue ; } if ( value == null || value . equals ( "" ) ) { value = typeCast ( injectionPattern . getDefaultValue ( ) ) ; if ( value == null || value . equals ( "" ) ) { String error_text = injectionPattern . getErrorText ( ) ; if ( error_text != null && ! error_text . equals ( "" ) ) { throw new ConfigException ( error_text ) ; } } } if ( value == null && valueMap != null && ! valueMap . containsKey ( injectionPattern . getKey ( ) ) ) { throw new ConfigException ( "\"${" + content + "}\" appears in config file cannot be expanded" ) ; } } return value ; }
Method used to parse the content inside pattern "${}"