All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.sporklibrary.binders.component.ComponentFieldBinder Maven / Gradle / Ivy

There is a newer version: 3.2.0
Show newest version
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