Class FieldUtils
- java.lang.Object
-
- org.apache.felix.scr.impl.inject.field.FieldUtils
-
public class FieldUtils extends Object
Utility methods for handling field injection.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFieldUtils.FieldSearchResultReturn type forsearchField(Class, String, ComponentLogger)
-
Constructor Summary
Constructors Constructor Description FieldUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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 StringtoString(Class<?> componentClass, Field field)Return a string representation of the field
-
-
-
Method Detail
-
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:
targetClass- The class of the componentfieldName- The name of the fieldlogger- A logger to log errors / problems- Returns:
- A field search result or
nullif an unexpected error occurred.
-
toString
public static String toString(Class<?> componentClass, Field field)
Return a string representation of the field- Parameters:
componentClass- The component classfield- The field- Returns:
- A string representation of the field
-
setField
public static void setField(Field f, Object component, Object value, ComponentLogger logger)
Set the field, type etc.- Parameters:
f- The fieldcomponent- The component instancevalue- The value to setlogger- The logger
-
-