code: public static GerritJsonEvent getEvent(JSONObject jsonObject) {
  
          GerritEventType type = GerritEventType.findByTypeValue(jsonObject.getString("type"));
          //the type has already been verified by the method that gets the JSONObject,
          //so any NullPointerExceptions or similar problems are the caller's own fault.
          Class<? extends GerritJsonEvent> clazz = type.getEventRepresentative();
          GerritJsonEvent event = null;
          try {
              logger.debug("Interesting event with a class defined. Searching shorthand constructor.");
              Constructor<? extends GerritJsonEvent> constructor = clazz.getConstructor(JSONObject.class);
              event = constructor.newInstance(jsonObject);
              logger.trace("Event created from shorthand constructor.");
          } catch (NoSuchMethodException ex) {
              logger.debug("Constructor with JSONObject as parameter missing, trying default constructor.", ex);
          } catch (Exception ex) {
              logger.debug("Error when using event constructor with JSONObject, trying default constructor.", ex);
          }
          if (event == null) {
              logger.debug("Trying default constructor.");
              try {
                  event = clazz.newInstance();
                  event.fromJson(jsonObject);
                  logger.trace("Event created from default constructor");
              } catch (InstantiationException ex) {
                  logger.error("Could not create an interesting GerritJsonEvent via default constructor "
                          + "(DESIGN ERROR).", ex);
              } catch (IllegalAccessException ex) {
                  logger.error("Could not create an interesting GerritJsonEvent via default constructor"
                          + "(DESIGN ERROR).", ex);
              }
          }
          logger.debug("Returning an event: {}", event);
          return event;
      }
docs: Creates a GerritJsonEvent DTO out of the provided JSONObject.
  The jsonObject is assumed to be interesting and usable
  as defined by {@link #getJsonObjectIfInterestingAndUsable(java.lang.String) }
  @param jsonObject the parsed JSON Object
  @return the POJO DTO representation of the jsonObject.