コード例 #1
0
  /**
   * Instantiates a new annotated field method.
   *
   * @param method the method
   * @param function the function
   */
  public AnnotatedFieldMethod(Method method, Field.Property function) {
    super(method);
    this.function = function;

    Dynamic runtime = method.getAnnotation(Dynamic.class);
    if (runtime == null) {
      throw new HeaderDefinitionError(
          method.getDeclaringClass(), "unable get field's annotated runtime");
    }

    if (runtime.field().length() != 0) {
      this.field = runtime.field();
    } else {
      this.field = guessFieldName(method.getName());
    }
  }
コード例 #2
0
  /**
   * Check annotation.
   *
   * @param method the method
   * @param fields the fields
   */
  public static void checkAnnotation(Method method, List<AnnotatedField> fields) {

    Dynamic runtime = method.getAnnotation(Dynamic.class);

    if (runtime.field().length() != 0) {

      boolean found = false;
      final String name = runtime.field();
      for (AnnotatedField f : fields) {
        if (f.getName().equals(name)) {
          found = true;
          break;
        }
      }

      if (!found) {
        throw new HeaderDefinitionError("field name defined in annotation ");
      }
    }
  }