Ejemplo n.º 1
0
  private static MemberBox extractSetMethod(Class<?> type, MemberBox[] methods, boolean isStatic) {
    //
    // Note: it may be preferable to allow NativeJavaMethod.findFunction()
    //       to find the appropriate setter; unfortunately, it requires an
    //       instance of the target arg to determine that.
    //

    // Make two passes: one to find a method with direct type assignment,
    // and one to find a widening conversion.
    for (int pass = 1; pass <= 2; ++pass) {
      for (int i = 0; i < methods.length; ++i) {
        MemberBox method = methods[i];
        if (!isStatic || method.isStatic()) {
          Class<?>[] params = method.argTypes;
          if (params.length == 1) {
            if (pass == 1) {
              if (params[0] == type) {
                return method;
              }
            } else {
              if (pass != 2) Kit.codeBug();
              if (params[0].isAssignableFrom(type)) {
                return method;
              }
            }
          }
        }
      }
    }
    return null;
  }
Ejemplo n.º 2
0
  private static MemberBox extractSetMethod(MemberBox[] methods, boolean isStatic) {

    for (int i = 0; i < methods.length; ++i) {
      MemberBox method = methods[i];
      if (!isStatic || method.isStatic()) {
        if (method.method().getReturnType() == Void.TYPE) {
          if (method.argTypes.length == 1) {
            return method;
          }
        }
      }
    }
    return null;
  }
Ejemplo n.º 3
0
 private static MemberBox extractGetMethod(MemberBox[] methods, boolean isStatic) {
   // Inspect the list of all MemberBox for the only one having no
   // parameters
   for (int methodIdx = 0; methodIdx < methods.length; methodIdx++) {
     MemberBox method = methods[methodIdx];
     // Does getter method have an empty parameter list with a return
     // value (eg. a getSomething() or isSomething())?
     if (method.argTypes.length == 0 && (!isStatic || method.isStatic())) {
       Class<?> type = method.method().getReturnType();
       if (type != Void.TYPE) {
         return method;
       }
       break;
     }
   }
   return null;
 }