/**
   * @param method the method
   * @param searchTopMethod search for top most overridden method
   * @return the corresponding element name
   */
  public static String getElementName(Method method, boolean searchTopMethod) {
    Method topMethod = method;

    if (searchTopMethod) {
      // Get top most method declaration
      Set<Method> hierarchy = MethodUtils.getOverrideHierarchy(method, Interfaces.INCLUDE);
      topMethod = IterableUtils.get(hierarchy, hierarchy.size() - 1);
    }

    // Get element name from method
    return getElementName(topMethod);
  }
  /**
   * @param type the class of the filter
   * @return the descriptor of the filter
   * @throws IncompatibleFilterException when several methods/events are incompatibles
   */
  private FilterDescriptor createDescriptor(Class<?> type) throws IncompatibleFilterException {
    // Proxy "loose" various reflection informations (like method parameter names)
    if (Proxy.isProxyClass(type)) {
      return getFilterDescriptor(type.getInterfaces());
    } else {
      FilterDescriptor descriptor = new FilterDescriptor();

      for (Method method : type.getMethods()) {
        // Get top most method declaration
        Set<Method> hierarchy = MethodUtils.getOverrideHierarchy(method, Interfaces.INCLUDE);
        Method topMethod = IterableUtils.get(hierarchy, hierarchy.size() - 1);

        // Get element name from method
        String elementName = getElementName(topMethod);

        // If a name can be found, continue
        if (elementName != null) {
          addElement(elementName, descriptor, topMethod);
        }
      }

      return descriptor;
    }
  }