use of org.apache.felix.ipojo.manipulator.metadata.annotation.visitor.generic.FieldGenericVisitor in project felix by apache.
the class LegacyGenericBindingRegistry method createBindings.
@Override
protected List<Binding> createBindings(final Type type) {
if (CUSTOM_HANDLER_PATTERN.matcher(type.getClassName()).matches()) {
Binding binding = new Binding();
binding.setAnnotationType(type);
binding.setPredicate(alwaysTrue());
binding.setFactory(new AnnotationVisitorFactory() {
// Need to build a new Element instance for each created visitor
public AnnotationVisitor newAnnotationVisitor(BindingContext context) {
if (context.getClassNode() != null) {
return new TypeGenericVisitor(context.getWorkbench(), Elements.buildElement(type));
} else if (context.getFieldNode() != null) {
return new FieldGenericVisitor(context.getWorkbench(), Elements.buildElement(type), context.getFieldNode());
} else if ((context.getMethodNode() != null) && (context.getParameterIndex() == BindingContext.NO_INDEX)) {
return new MethodGenericVisitor(context.getWorkbench(), Elements.buildElement(type), context.getMethodNode());
} else {
// last case: method parameter annotation
return new ParameterGenericVisitor(context.getWorkbench(), Elements.buildElement(type), context.getMethodNode(), context.getParameterIndex());
}
}
@Override
public String toString() {
return "LegacyGenericVisitorFactory";
}
});
// Return the produced generic binding
return singletonList(binding);
}
return emptyList();
}
Aggregations