Class ReflectionInjector
java.lang.Object
honeyroasted.fill.reflect.ReflectionInjector
- All Implemented Interfaces:
Injector<ReflectionInjector, ReflectionInjectorBuilder>
public class ReflectionInjector
extends Object
implements Injector<ReflectionInjector, ReflectionInjectorBuilder>
An
Injector utilizing reflection to inject into fields, methods, and constructors-
Constructor Summary
ConstructorsConstructorDescriptionReflectionInjector(Binding binding, honeyroasted.jype.system.JTypeSystem system, BiPredicate<InjectionTarget, Object> dummyObjectMatcher, Function<Class<?>, Collection<Field>> fieldAggregator, Function<Class<?>, Collection<Method>> methodAggregator, Function<Class<?>, Collection<Constructor<?>>> constructorAggregator) Creates a newReflectionInjectorwith the givenBinding -
Method Summary
Modifier and TypeMethodDescriptionstatic ReflectionInjectorBuilderbuilder()<T> TCreates a new instance of the given class by attempting to inject into a constructorvoidAttempts to inject the appropriate fields, and call the appropriate injection methods, on the given objectvoidinjectStatic(Class<?> cls) Attempts to inject the appropriate static fields, and call the appropriate static injection methods, on the given objectCopies thisInjector's settings into a builder of the appropriate type, and returns it.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface honeyroasted.fill.Injector
createAndInject
-
Constructor Details
-
ReflectionInjector
public ReflectionInjector(Binding binding, honeyroasted.jype.system.JTypeSystem system, BiPredicate<InjectionTarget, Object> dummyObjectMatcher, Function<Class<?>, Collection<Field>> fieldAggregator, Function<Class<?>, Collection<Method>> methodAggregator, Function<Class<?>, Collection<Constructor<?>>> constructorAggregator) Creates a newReflectionInjectorwith the givenBinding- Parameters:
binding- The binding for this injectorsystem- TheJTypeSystemto use for type logicdummyObjectMatcher- The predicate to use for testing if a value is over-writablefieldAggregator- The function used to obtain injectable field candidates from a givenClassmethodAggregator- The function used to obtain injectable method candidates from a givenClassconstructorAggregator- The function used to obtain injectable constructor candidates from a givenClass
-
-
Method Details
-
toBuilder
Description copied from interface:InjectorCopies thisInjector's settings into a builder of the appropriate type, and returns it.- Specified by:
toBuilderin interfaceInjector<ReflectionInjector, ReflectionInjectorBuilder>- Returns:
- A new builder with this
Injector's settings
-
create
Description copied from interface:InjectorCreates a new instance of the given class by attempting to inject into a constructor- Specified by:
createin interfaceInjector<ReflectionInjector, ReflectionInjectorBuilder>- Type Parameters:
T- The type of the class- Parameters:
cls- The class to instantiate- Returns:
- A new instance of
T
-
inject
Description copied from interface:InjectorAttempts to inject the appropriate fields, and call the appropriate injection methods, on the given object- Specified by:
injectin interfaceInjector<ReflectionInjector, ReflectionInjectorBuilder>- Parameters:
object- The object to inject into
-
injectStatic
Description copied from interface:InjectorAttempts to inject the appropriate static fields, and call the appropriate static injection methods, on the given object- Specified by:
injectStaticin interfaceInjector<ReflectionInjector, ReflectionInjectorBuilder>- Parameters:
cls- The class to inject into
-
builder
- Returns:
- A new
BindingBuilder
-