use of org.qi4j.runtime.injection.InjectedFieldModel in project qi4j-sdk by Qi4j.
the class MixinsModel method bind.
// Binding
@Override
public void bind(final Resolution resolution) throws BindingException {
// Order mixins based on @This usages
UsageGraph<MixinModel> deps = new UsageGraph<MixinModel>(mixinModels, new Uses(), true);
mixinModels = deps.resolveOrder();
// Populate mappings
for (int i = 0; i < mixinModels.size(); i++) {
MixinModel mixinModel = mixinModels.get(i);
mixinIndex.put(mixinModel.mixinClass(), i);
}
for (Map.Entry<Method, MixinModel> methodClassEntry : methodImplementation.entrySet()) {
methodIndex.put(methodClassEntry.getKey(), mixinIndex.get(methodClassEntry.getValue().mixinClass()));
}
for (MixinModel mixinModel : mixinModels) {
mixinModel.accept(new HierarchicalVisitorAdapter<Object, Object, BindingException>() {
@Override
public boolean visitEnter(Object visited) throws BindingException {
if (visited instanceof InjectedFieldModel) {
InjectedFieldModel fieldModel = (InjectedFieldModel) visited;
fieldModel.bind(resolution.forField(fieldModel.field()));
return false;
} else if (visited instanceof Binder) {
Binder constructorsModel = (Binder) visited;
constructorsModel.bind(resolution);
return false;
}
return true;
}
@Override
public boolean visit(Object visited) throws BindingException {
if (visited instanceof Binder) {
((Binder) visited).bind(resolution);
}
return true;
}
});
}
}
Aggregations