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
}
}
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;
}
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();
}
}
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();
}
}
}
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;
}
Aggregations