Class FieldUtils
java.lang.Object
org.apache.felix.scr.impl.inject.field.FieldUtils
Utility methods for handling field injection.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Return type forsearchField(Class, String, ComponentLogger)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FieldUtils.FieldSearchResult
searchField
(Class<?> componentClass, String fieldName, ComponentLogger logger) Searches the field namedfieldName
in the giventargetClass
.static void
setField
(Field f, Object component, Object value, ComponentLogger logger) Set the field, type etc.static String
Return a string representation of the field
-
Constructor Details
-
FieldUtils
public FieldUtils()
-
-
Method Details
-
searchField
public static FieldUtils.FieldSearchResult searchField(Class<?> componentClass, String fieldName, ComponentLogger logger) Searches the field namedfieldName
in the giventargetClass
. If the target class has no acceptable field the class hierarchy is traversed until a field is found or the root of the class hierarchy is reached without finding a field.If an unexpected error occurs while searching,
null
is returned. In all other cases aFieldSearchResult
is returned. If no field is found,FieldSearchResult#field
is set tonull
. If the field is found, but not usable (e.g. due to visibility restrictions),FieldSearchResult#usable
is set tofalse
.- Parameters:
targetClass
- The class of the componentfieldName
- The name of the fieldlogger
- A logger to log errors / problems- Returns:
- A field search result or
null
if an unexpected error occurred.
-
toString
Return a string representation of the field- Parameters:
componentClass
- The component classfield
- The field- Returns:
- A string representation of the field
-
setField
Set the field, type etc.- Parameters:
f
- The fieldcomponent
- The component instancevalue
- The value to setlogger
- The logger
-