Class AnnotationHelper
- java.lang.Object
-
- de.fraunhofer.iosb.ilt.configurable.annotations.AnnotationHelper
-
public class AnnotationHelper extends Object
- Author:
- Hylke van der Schaaf
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <E,F,T extends ConfigEditor>
TcreateEditor(Class<T> editorForClass, Field field, E context, F edtCtx)static <E,F,T extends ConfigEditor>
TcreateEditor(Class<T> editorForClass, Field field, E context, F edtCtx, String key)static Set<String>csvToReadOnlySet(String csv)static <C,D>
Optional<EditorMap<?>>generateEditorFromAnnotations(Configurable<C,D> instance, C context, D edtCtx)Generate the editor for the given configurable instance.static <C,D>
Optional<EditorMap<?>>generateEditorFromAnnotations(Class<?> configurableClass, C context, D edtCtx)Generate the editor for the given configurable instance.static Optional<Constructor<?>>getConfigurableConstructor(Class<?> configurableClass)static booleanhasConfigurableConstructorAnnotation(Class<?> configurableClass)static booleanhasConfigurableConstructorParameter(Object instance, String jsonField)static <T,R,E>
TinstantiateFrom(Constructor<?> configurableConstructor, com.google.gson.JsonElement classConfig, R runtimeContext, E editorContext)
-
-
-
Method Detail
-
generateEditorFromAnnotations
public static final <C,D> Optional<EditorMap<?>> generateEditorFromAnnotations(Configurable<C,D> instance, C context, D edtCtx)
Generate the editor for the given configurable instance. The editor settings will be taken from annotations on the Class of the instance, and its super classes.- Type Parameters:
C- The class type that provides context at runtime.D- The class type that provides context while editing.- Parameters:
instance- The configurable instance to generate an editor for.context- The instance that provides context at runtime.edtCtx- The instance that provides context while editing.- Returns:
- an editor for the given Configurable instance.
-
generateEditorFromAnnotations
public static final <C,D> Optional<EditorMap<?>> generateEditorFromAnnotations(Class<?> configurableClass, C context, D edtCtx)
Generate the editor for the given configurable instance. The editor settings will be taken from annotations on the configurable Class, and its super classes.- Type Parameters:
C- The class type that provides context at runtime.D- The class type that provides context while editing.- Parameters:
configurableClass- The configurable class to generate an editor for.context- The instance that provides context at runtime.edtCtx- The instance that provides context while editing.- Returns:
- an editor for the given Configurable class, or an empty optional if no Configurable annotations exist.
-
createEditor
public static <E,F,T extends ConfigEditor> T createEditor(Class<T> editorForClass, Field field, E context, F edtCtx) throws ReflectiveOperationException
- Throws:
ReflectiveOperationException
-
createEditor
public static <E,F,T extends ConfigEditor> T createEditor(Class<T> editorForClass, Field field, E context, F edtCtx, String key) throws IllegalAccessException, ReflectiveOperationException
-
hasConfigurableConstructorAnnotation
public static boolean hasConfigurableConstructorAnnotation(Class<?> configurableClass)
-
getConfigurableConstructor
public static Optional<Constructor<?>> getConfigurableConstructor(Class<?> configurableClass)
-
instantiateFrom
public static <T,R,E> T instantiateFrom(Constructor<?> configurableConstructor, com.google.gson.JsonElement classConfig, R runtimeContext, E editorContext) throws ReflectiveOperationException, IllegalArgumentException, ConfigurationException
-
-