- java.lang.Object
-
- io.github.suppierk.inject.graph.Node<T>
-
- io.github.suppierk.inject.graph.ReflectionNode<T>
-
- Type Parameters:
T- is the type of the instance this node refers to
- All Implemented Interfaces:
jakarta.inject.Provider<T>,java.io.Closeable,java.lang.AutoCloseable,java.util.function.Supplier<T>
- Direct Known Subclasses:
ConstructsNew,ProvidesNew
public abstract class ReflectionNode<T> extends Node<T>
Defines a baseline structure for the dependency graph nodes which can produce new object instances.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedReflectionNode(InjectorReference injectorReference, java.util.List<ParameterInformation> parametersInformation, java.util.List<FieldInformation> fieldsInformation, Key<?>... extraParentKeys)Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Object[]createArguments()Create an array of arguments for instantiation method invocation.booleanequals(java.lang.Object o)java.util.List<FieldInformation>fieldsInformation()inthashCode()protected TinjectFields(T instance)Perform in-place field injection into an object instance.static booleanisNotSupportedWrapperClass(java.lang.Class<?> clazz)Checks if currentClassis eitherProviderorSupplier.java.util.List<ParameterInformation>parametersInformation()java.util.Set<Key<?>>requiredParentKeys()-
Methods inherited from class io.github.suppierk.inject.graph.Node
copy, createOnCloseConsumer, emptyConsumer, injectorReference, parentKeys, toYamlString
-
-
-
-
Constructor Detail
-
ReflectionNode
protected ReflectionNode(InjectorReference injectorReference, java.util.List<ParameterInformation> parametersInformation, java.util.List<FieldInformation> fieldsInformation, Key<?>... extraParentKeys)
Default constructor.- Parameters:
injectorReference- for dependency lookupsparametersInformation- of the method to be invoked during dependency injectionfieldsInformation- of the class to be set during dependency injectionextraParentKeys- this node depends upon
-
-
Method Detail
-
parametersInformation
public java.util.List<ParameterInformation> parametersInformation()
-
fieldsInformation
public java.util.List<FieldInformation> fieldsInformation()
-
requiredParentKeys
public java.util.Set<Key<?>> requiredParentKeys()
- Overrides:
requiredParentKeysin classNode<T>
-
createArguments
protected java.lang.Object[] createArguments()
Create an array of arguments for instantiation method invocation.- Returns:
- an array of objects to serve as method arguments
-
injectFields
protected T injectFields(T instance) throws java.lang.IllegalAccessException
Perform in-place field injection into an object instance.- Parameters:
instance- to inject fields into- Returns:
- an original object instance with injected fields
- Throws:
java.lang.IllegalAccessException- if we cannot access the field to inject the value into
-
isNotSupportedWrapperClass
public static boolean isNotSupportedWrapperClass(java.lang.Class<?> clazz)
Checks if currentClassis eitherProviderorSupplier.- Parameters:
clazz- to check- Returns:
true, if theClassis eitherProviderorSupplier
-
-