use of org.qi4j.tools.model.descriptor.ServiceUsage in project qi4j-sdk by Qi4j.
the class TableRowUtilities method toTableRows.
public static List<TableRow> toTableRows(List<ServiceUsage> serviceUsages) {
List<TableRow> rows = new ArrayList<>();
for (ServiceUsage usage : serviceUsages) {
TableRow row = new TableRow(5);
if (usage.ownerDescriptor() instanceof MixinDetailDescriptor) {
MixinDetailDescriptor mixinDescriptor = (MixinDetailDescriptor) usage.ownerDescriptor();
row.set(0, mixinDescriptor.composite());
row.set(1, usage.field());
row.set(2, mixinDescriptor.composite().module());
row.set(3, mixinDescriptor.composite().module().layer());
} else {
// assume ObjectDetailDescriptor
ObjectDetailDescriptor objectDescriptor = (ObjectDetailDescriptor) usage.ownerDescriptor();
row.set(0, objectDescriptor);
row.set(1, usage.field());
row.set(2, objectDescriptor.module());
row.set(3, objectDescriptor.module().layer());
}
rows.add(row);
}
return rows;
}
use of org.qi4j.tools.model.descriptor.ServiceUsage in project qi4j-sdk by Qi4j.
the class ServiceUsageFinder method collectInInjectedField.
private void collectInInjectedField(Iterable<InjectedFieldDetailDescriptor> iter, Object ownerDescriptor) {
for (InjectedFieldDetailDescriptor descriptorField : iter) {
DependencyDescriptor dependencyDescriptor = descriptorField.descriptor().dependency();
Annotation annotation = dependencyDescriptor.injectionAnnotation();
Class<? extends Annotation> clazz = annotation.annotationType();
if (Uses.class.equals(clazz) || Service.class.equals(clazz)) {
boolean used = false;
if (dependencyDescriptor.injectionType().equals(first(this.descriptor.descriptor().types()))) {
ServiceUsage usage;
if (ownerDescriptor instanceof MixinDetailDescriptor) {
MixinDetailDescriptor mixinDescriptor = (MixinDetailDescriptor) ownerDescriptor;
usage = new ServiceUsage(mixinDescriptor.composite(), descriptorField, mixinDescriptor.composite().module(), mixinDescriptor.composite().module().layer());
} else {
// assume ObjectDetailDescriptor
ObjectDetailDescriptor objectDescriptor = (ObjectDetailDescriptor) ownerDescriptor;
usage = new ServiceUsage(objectDescriptor, descriptorField, objectDescriptor.module(), objectDescriptor.module().layer());
}
usages.add(usage);
}
}
}
}
use of org.qi4j.tools.model.descriptor.ServiceUsage in project qi4j-sdk by Qi4j.
the class ServiceUsagePane method setDescriptor.
@Override
protected void setDescriptor(Object objectDesciptor) {
clear();
if (!(objectDesciptor instanceof ServiceDetailDescriptor)) {
return;
}
ServiceDetailDescriptor descriptor = (ServiceDetailDescriptor) objectDesciptor;
List<ServiceUsage> serviceUsages = DescriptorUtilities.findServiceUsage(descriptor);
usageTableModel.addRows(TableRowUtilities.toTableRows(serviceUsages));
}
Aggregations