code: 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);
                  }
              }
          }
      }
docs: Decorate the action with optional events.
  
  @param a  the action to decorate
  @param in the JSON message containing the event at the "hook" key
  @throws JSONConverterException in case of error