コード例 #1
0
ファイル: Reflection.java プロジェクト: jysunhy/disl-android
  /**
   * Returns methods implemented by a particular interface.
   *
   * @param interfaceName
   * @return
   */
  public static List<Method> getInterfaceMethods(final String interfaceName) {
    final List<Method> result = Lists.newArrayList();

    try {
      final Class<?> interfaceClass = Class.forName(interfaceName);

      // add interface methods to the list
      for (final Method method : interfaceClass.getMethods()) {
        result.add(method);
      }
    } catch (final ClassNotFoundException cnfe) {
      // just emit a warning and return an empty list
      System.err.println("warning: unable to get class for interface " + interfaceName);
    }

    return result;
  }