public static T normalize()

in src/main/java/com/googlesource/gerrit/plugins/rabbitmq/config/section/Sections.java [113:136]


  public static <T extends Section> T normalize(T section) {
    Field[] fs = section.getClass().getFields();
    for (Field f : fs) {
      try {
        if (f.getType() == Integer.class && f.isAnnotationPresent(Limit.class)) {
          Object obj = f.get(section);
          if (obj != null) {
            Integer val = Integer.class.cast(obj);
            Limit a = f.getAnnotation(Limit.class);
            if (a.min() != -1 && val < a.min()) {
              val = a.min();
            }
            if (a.max() != -1 && val > a.max()) {
              val = a.max();
            }
            f.set(section, val);
          }
        }
      } catch (IllegalAccessException ex) {
        LOGGER.warn("Cannot access field {}. Cause: {}", f.getName(), ex.getMessage());
      }
    }
    return section;
  }