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 classReturn type forsearchField(Class, String, ComponentLogger) -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FieldUtils.FieldSearchResultsearchField(Class<?> componentClass, String fieldName, ComponentLogger logger) Searches the field namedfieldNamein the giventargetClass.static voidsetField(Field f, Object component, Object value, ComponentLogger logger) Set the field, type etc.static StringReturn 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 namedfieldNamein 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,
nullis returned. In all other cases aFieldSearchResultis returned. If no field is found,FieldSearchResult#fieldis set tonull. If the field is found, but not usable (e.g. due to visibility restrictions),FieldSearchResult#usableis set tofalse.- Parameters:
fieldName- The name of the fieldlogger- A logger to log errors / problemstargetClass- The class of the component- Returns:
- A field search result or
nullif 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
-