Beispiel #1
0
  /**
   * The Methods tab should show all the methods of all Mixins (private and public separated) that
   * don't return one of Property, Association or ManyAssociation.
   *
   * <p>"private" and "public" refers to if the interface they are declared in is extended by the
   * Composite. If yes, then it is a public method, meaning, clients can call it. If no, then it is
   * a private mixin type, and can only be used internally through @This injections.
   */
  private List<CompositeMethodDetailDescriptor> findMethod(
      Iterable<CompositeMethodDetailDescriptor> iter) {
    List<CompositeMethodDetailDescriptor> publicList =
        new ArrayList<CompositeMethodDetailDescriptor>();
    List<CompositeMethodDetailDescriptor> privateList =
        new ArrayList<CompositeMethodDetailDescriptor>();

    for (CompositeMethodDetailDescriptor descriptor : iter) {
      Class compositeClass = descriptor.composite().descriptor().type();
      Class mixinMethodClass = descriptor.descriptor().method().getDeclaringClass();
      if (mixinMethodClass.isAssignableFrom(compositeClass)) {
        publicList.add(descriptor);
      } else {
        privateList.add(descriptor);
      }
    }

    // combine into one list, with public listed first then private
    publicList.addAll(privateList);

    // filter Property, Association, and ManyAssociation
    doFilter(publicList);

    return publicList;
  }
Beispiel #2
0
  /**
   * Do the filter for method return type (Property, Association, ManyAssociation) by removing the
   * entry from the list.
   *
   * @param list list of CompositeMethodDetailDescriptor
   */
  private void doFilter(List<CompositeMethodDetailDescriptor> list) {
    if (list.isEmpty()) {
      return;
    }

    Iterator<CompositeMethodDetailDescriptor> iter = list.iterator();
    while (iter.hasNext()) {
      CompositeMethodDetailDescriptor descriptor = iter.next();
      Method method = descriptor.descriptor().method();
      if (Property.class.isAssignableFrom(method.getReturnType())) {
        iter.remove();
      } else if (Association.class.isAssignableFrom(method.getReturnType())) {
        iter.remove();
      } else if (ManyAssociation.class.isAssignableFrom(method.getReturnType())) {
        iter.remove();
      }
    }
  }