@ Action ( name = "Default if empty" , description = OPERATION_DESC , outputs = { @ Output ( value = RETURN_CODE , description = RETURN_CODE_DESC ) , @ Output ( value = RETURN_RESULT , description = RETURN_RESULT_DESC ) , @ Output ( value = EXCEPTION , description = EXCEPTION_DESC ) , } , responses = { @ Response ( text = SUCCESS , field = RETURN_CODE , value = ReturnCodes . SUCCESS , matchType = COMPARE_EQUAL , responseType = RESOLVED , description = SUCCESS_DESC ) , @ Response ( text = FAILURE , field = RETURN_CODE , value = ReturnCodes . FAILURE , matchType = COMPARE_EQUAL , responseType = ERROR , isOnFail = true , description = FAILURE_DESC ) } ) public Map < String , String > execute ( @ Param ( value = INITIAL_VALUE , description = INITIAL_VALUE_DESC ) String initialValue , @ Param ( value = DEFAULT_VALUE , required = true , description = DEFAULT_VALUE_DESC ) String defaultValue , @ Param ( value = TRIM , description = TRIM_DESC ) String trim ) { try { trim = defaultIfBlank ( trim , BooleanValues . TRUE ) ; final boolean validTrim = toBoolean ( trim ) ; return getSuccessResultsMap ( DefaultIfEmptyService . defaultIfBlankOrEmpty ( initialValue , defaultValue , validTrim ) ) ; } catch ( Exception e ) { return getFailureResultsMap ( e ) ; } }
This operation checks if a string is blank or empty and if it s true a default value will be assigned instead of the initial string .