public static T initialize()

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


  public static <T extends Section> T initialize(T section) {
    Field[] fs = section.getClass().getFields();
    for (Field f : fs) {
      try {
        if (f.isAnnotationPresent(Default.class)) {
          Default a = f.getAnnotation(Default.class);
          Class<?> type = f.getType();
          if (type == String.class) {
            f.set(section, a.value());
          } else if (type == Integer.class) {
            f.set(section, Integer.valueOf(a.value()));
          } else if (type == Long.class) {
            f.set(section, Long.valueOf(a.value()));
          } else if (type == Boolean.class) {
            f.set(section, Boolean.valueOf(a.value()));
          }
        }
      } catch (IllegalAccessException ex) {
        LOGGER.warn("Cannot access field {}. Cause: {}", f.getName(), ex.getMessage());
      }
    }
    return section;
  }