private void attachEvents ( Action a , JSONObject in ) throws JSONConverterException { if ( in . containsKey ( HOOK_LABEL ) ) { JSONObject hooks = ( JSONObject ) in . get ( HOOK_LABEL ) ; for ( Map . Entry < String , Object > e : hooks . entrySet ( ) ) { String k = e . getKey ( ) ; try { Action . Hook h = Action . Hook . valueOf ( k . toUpperCase ( ) ) ; for ( Object o : ( JSONArray ) e . getValue ( ) ) { a . addEvent ( h , eventFromJSON ( ( JSONObject ) o ) ) ; } } catch ( IllegalArgumentException ex ) { throw new JSONConverterException ( "Unsupported hook type '" + k + "'" , ex ) ; } } } }
Decorate the action with optional events .