예제 #1
0
  public static Collection<String> getAllOutputNames(Class<?> clz) {
    Collection<String> result = new Vector<String>();

    for (Field f : clz.getDeclaredFields()) {
      if (f.isAnnotationPresent(Out.class)) {
        Out outputAnnotation = f.getAnnotation(Out.class);
        result.add(outputAnnotation.name());
      }
    }

    return result;
  }
예제 #2
0
  /**
   * Based on annotated output field name that we wanted to access, using this utility method we can
   * get the value of the current field.
   *
   * @param instance
   * @param outputName
   * @return
   * @throws IllegalArgumentException
   * @throws IllegalAccessException
   */
  public static Object getOutputField(Object instance, String outputName)
      throws IllegalArgumentException, IllegalAccessException {
    Object result = null;
    for (Field f : instance.getClass().getDeclaredFields()) {
      if (f.isAnnotationPresent(Out.class)) {
        Out outputAnnotation = f.getAnnotation(Out.class);
        if (outputName.equals(outputAnnotation.name())) {
          return f.get(instance);
        }
      }
    }

    return result;
  }