@ Action ( name = "List Remover" , outputs = { @ Output ( RESPONSE ) , @ Output ( RETURN_RESULT ) , @ Output ( RETURN_CODE ) } , responses = { @ Response ( text = SUCCESS , field = RETURN_CODE , value = RETURN_CODE_SUCCESS , matchType = MatchType . COMPARE_EQUAL ) , @ Response ( text = FAILURE , field = RETURN_CODE , value = RETURN_CODE_FAILURE , matchType = MatchType . COMPARE_EQUAL , isOnFail = true , isDefault = true ) } ) public Map < String , String > removeElement ( @ Param ( value = LIST , required = true ) String list , @ Param ( value = ELEMENT , required = true ) String index , @ Param ( value = DELIMITER , required = true ) String delimiter ) { Map < String , String > result = new HashMap <> ( ) ; try { if ( StringUtils . isEmpty ( list ) || StringUtils . isEmpty ( index ) || StringUtils . isEmpty ( delimiter ) ) { throw new RuntimeException ( EMPTY_INPUT_EXCEPTION ) ; } else { String [ ] elements = StringUtils . split ( list , delimiter ) ; elements = ArrayUtils . remove ( elements , Integer . parseInt ( index ) ) ; result . put ( RESPONSE , SUCCESS ) ; result . put ( RETURN_RESULT , StringUtils . join ( elements , delimiter ) ) ; result . put ( RETURN_CODE , RETURN_CODE_SUCCESS ) ; } } catch ( Exception e ) { result . put ( RESPONSE , FAILURE ) ; result . put ( RETURN_RESULT , e . getMessage ( ) ) ; result . put ( RETURN_CODE , RETURN_CODE_FAILURE ) ; } return result ; }
This method removes an element from a list of strings .