Search in sources :

Example 1 with CompositeMethodDetailDescriptor

use of org.qi4j.tools.model.descriptor.CompositeMethodDetailDescriptor in project qi4j-sdk by Qi4j.

the class MethodPane method setDescriptor.

@Override
protected void setDescriptor(Object objectDesciptor) {
    clear();
    if (objectDesciptor instanceof CompositeDetailDescriptor) {
        CompositeDetailDescriptor descriptor = ((CompositeDetailDescriptor) objectDesciptor);
        List<CompositeMethodDetailDescriptor> list = DescriptorUtilities.findMethod(descriptor);
        for (CompositeMethodDetailDescriptor methodDescriptor : list) {
            methodListModel.addElement(methodDescriptor);
        }
        if (!methodListModel.isEmpty()) {
            methodList.setSelectedIndex(0);
        }
    } else if (objectDesciptor instanceof ObjectDetailDescriptor) {
    // Object does not have methods
    }
}
Also used : CompositeMethodDetailDescriptor(org.qi4j.tools.model.descriptor.CompositeMethodDetailDescriptor) ObjectDetailDescriptor(org.qi4j.tools.model.descriptor.ObjectDetailDescriptor) CompositeDetailDescriptor(org.qi4j.tools.model.descriptor.CompositeDetailDescriptor)

Example 2 with CompositeMethodDetailDescriptor

use of org.qi4j.tools.model.descriptor.CompositeMethodDetailDescriptor in project qi4j-sdk by Qi4j.

the class MethodFinder method findMethod.

/**
     * 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.
     *
     * "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<>();
    List<CompositeMethodDetailDescriptor> privateList = new ArrayList<>();
    for (CompositeMethodDetailDescriptor descriptor : iter) {
        CompositeDescriptor compositeDescriptor = descriptor.composite().descriptor();
        Iterable<Class<?>> compositeType = compositeDescriptor.types();
        Class<?> mixinMethodClass = descriptor.descriptor().method().getDeclaringClass();
        for (Class<?> compositeClass : compositeType) {
            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, ManyAssociation and NamedAssociation
    doFilter(publicList);
    return publicList;
}
Also used : CompositeMethodDetailDescriptor(org.qi4j.tools.model.descriptor.CompositeMethodDetailDescriptor) ArrayList(java.util.ArrayList) CompositeDescriptor(org.qi4j.api.composite.CompositeDescriptor)

Example 3 with CompositeMethodDetailDescriptor

use of org.qi4j.tools.model.descriptor.CompositeMethodDetailDescriptor in project qi4j-sdk by Qi4j.

the class StateFinder method doFilter.

/**
     * Do the filter for method return type (Property, Association, ManyAssociation, NamedAssociation)
     * by removing the entry from the list if not the above.
     *
     * @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()) || Association.class.isAssignableFrom(method.getReturnType()) || ManyAssociation.class.isAssignableFrom(method.getReturnType()) || NamedAssociation.class.isAssignableFrom(method.getReturnType())) {
            continue;
        }
        iter.remove();
    }
}
Also used : Association(org.qi4j.api.association.Association) ManyAssociation(org.qi4j.api.association.ManyAssociation) NamedAssociation(org.qi4j.api.association.NamedAssociation) CompositeMethodDetailDescriptor(org.qi4j.tools.model.descriptor.CompositeMethodDetailDescriptor) NamedAssociation(org.qi4j.api.association.NamedAssociation) Method(java.lang.reflect.Method) Property(org.qi4j.api.property.Property)

Example 4 with CompositeMethodDetailDescriptor

use of org.qi4j.tools.model.descriptor.CompositeMethodDetailDescriptor in project qi4j-sdk by Qi4j.

the class MethodFinder method doFilter.

/**
     * Do the filter for method return type (Property, Association, ManyAssociation, NamedAssociation)
     * 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();
        } else if (NamedAssociation.class.isAssignableFrom(method.getReturnType())) {
            iter.remove();
        }
    }
}
Also used : Association(org.qi4j.api.association.Association) ManyAssociation(org.qi4j.api.association.ManyAssociation) NamedAssociation(org.qi4j.api.association.NamedAssociation) CompositeMethodDetailDescriptor(org.qi4j.tools.model.descriptor.CompositeMethodDetailDescriptor) NamedAssociation(org.qi4j.api.association.NamedAssociation) Method(java.lang.reflect.Method)

Example 5 with CompositeMethodDetailDescriptor

use of org.qi4j.tools.model.descriptor.CompositeMethodDetailDescriptor in project qi4j-sdk by Qi4j.

the class StateFinder method findState.

private List<CompositeMethodDetailDescriptor> findState(Iterable<CompositeMethodDetailDescriptor> iter) {
    List<CompositeMethodDetailDescriptor> publicList = new ArrayList<>();
    List<CompositeMethodDetailDescriptor> privateList = new ArrayList<>();
    for (CompositeMethodDetailDescriptor descriptor : iter) {
        Class<?> compositeClass = first(descriptor.composite().descriptor().types());
        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, ManyAssociation and NamedAssociation
    doFilter(publicList);
    return publicList;
}
Also used : CompositeMethodDetailDescriptor(org.qi4j.tools.model.descriptor.CompositeMethodDetailDescriptor) ArrayList(java.util.ArrayList)

Aggregations

CompositeMethodDetailDescriptor (org.qi4j.tools.model.descriptor.CompositeMethodDetailDescriptor)6 Method (java.lang.reflect.Method)2 ArrayList (java.util.ArrayList)2 Association (org.qi4j.api.association.Association)2 ManyAssociation (org.qi4j.api.association.ManyAssociation)2 NamedAssociation (org.qi4j.api.association.NamedAssociation)2 CompositeDetailDescriptor (org.qi4j.tools.model.descriptor.CompositeDetailDescriptor)2 ObjectDetailDescriptor (org.qi4j.tools.model.descriptor.ObjectDetailDescriptor)2 CompositeDescriptor (org.qi4j.api.composite.CompositeDescriptor)1 Property (org.qi4j.api.property.Property)1