
com.github.nill14.utils.init.impl.SimplePropertyResolver Maven / Gradle / Ivy
The newest version!
package com.github.nill14.utils.init.impl;
import java.lang.annotation.Annotation;
import java.util.Collection;
import java.util.Map;
import javax.inject.Provider;
import com.github.nill14.utils.init.api.BindingKey;
import com.github.nill14.utils.init.api.IParameterType;
import com.github.nill14.utils.init.api.IPojoFactory;
import com.github.nill14.utils.init.api.IPropertyResolver;
import com.github.nill14.utils.init.api.IScope;
import com.github.nill14.utils.init.binding.impl.Binding;
import com.github.nill14.utils.init.binding.impl.BindingTarget;
import com.github.nill14.utils.init.binding.target.LinkedBindingTarget;
import com.github.nill14.utils.init.scope.IScopeStrategy;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Multimap;
import com.google.common.reflect.TypeToken;
public class SimplePropertyResolver extends AbstractPropertyResolver implements IPropertyResolver {
private static final long serialVersionUID = 6151314354173527220L;
private final ImmutableMap, Binding>> bindings;
private final Multimap, Binding>> typeBindings;
private final ImmutableMap, IPojoFactory>> bindingFactories;
public SimplePropertyResolver(ImmutableList> bindings, ChainingPojoInitializer initializer) {
super(initializer);
this.bindings = BinderUtils.prepareAndIndexBindings(bindings);
this.typeBindings = BinderUtils.indexTypeBindings(this.bindings.values());
this.bindingFactories = BinderUtils.indexFactories(this.bindings.values());
}
public SimplePropertyResolver(ImmutableList> bindings, ChainingPropertyResolver parent) {
super(parent);
this.bindings = BinderUtils.prepareAndIndexBindings(bindings);
this.typeBindings = BinderUtils.indexTypeBindings(this.bindings.values());
this.bindingFactories = BinderUtils.indexFactories(this.bindings.values());
}
@Override
protected Object findByName(String name, IParameterType type, CallerContext context) {
return null;
}
@Override
protected Object findByType(IParameterType type, CallerContext context) {
return resolveSingle(type, context);
}
@SuppressWarnings("unchecked")
@Override
protected Collection> findAllByType(IParameterType type, CallerContext context) {
Collection> bindings = typeBindings.get(type.getToken());
ImmutableList.Builder
© 2015 - 2025 Weber Informatics LLC | Privacy Policy