
io.github.sporklibrary.binders.component.ComponentFieldBinder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spork Show documentation
Show all versions of spork Show documentation
Annotation binding library
package io.github.sporklibrary.binders.component;
import io.github.sporklibrary.annotations.BindComponent;
import io.github.sporklibrary.binders.FieldBinder;
import io.github.sporklibrary.reflection.AnnotatedField;
import io.github.sporklibrary.reflection.AnnotatedFields;
/**
* The default FieldBinder that binds field annotated with the Bind annotation.
*/
public class ComponentFieldBinder implements FieldBinder {
private final ComponentInstanceManager componentInstanceManager = new ComponentInstanceManager();
@Override
public Class getAnnotationClass() {
return BindComponent.class;
}
@Override
public void bind(Object object, AnnotatedField annotatedField) {
Object instance = componentInstanceManager.getInstance(object, annotatedField);
AnnotatedFields.setValue(annotatedField, object, instance);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy