Class GeneratorUtils
- java.lang.Object
-
- org.uberfire.annotations.processors.GeneratorUtils
-
public class GeneratorUtils extends Object
Utilities for code generation
-
-
Constructor Summary
Constructors Constructor Description GeneratorUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleandebugLoggingEnabled()static AnnotationValueextractAnnotationPropertyValue(Elements elementUtils, AnnotationMirror annotation, CharSequence annotationProperty)static List<AnnotationMirror>extractAnnotationsFromAnnotation(Elements elementUtils, Element element, String annotationName, String paramName)Pulls nested annotations out of the annotation that contains them.static StringextractAnnotationStringValue(Elements elementUtils, AnnotationMirror annotation, CharSequence paramName)static Collection<String>extractValue(AnnotationValue value)Provides a uniform way of working with single- and multi-valued AnnotationValue objects.static StringformatAssociatedResources(Collection<String> resourceTypes)static List<String>getAllQualifiersDeclarationFromType(TypeElement element)This method builds a list of all qualifier annotations source-code declaration that annotates the passed element.static AnnotationMirrorgetAnnotation(Elements elementUtils, Element annotationTarget, String annotationName)static StringgetBeanActivatorClassName(TypeElement classElement, ProcessingEnvironment processingEnvironment)static StringgetBodyHeightMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)static StringgetContextIdMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)static StringgetDefaultPositionMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)Get the method name annotated with@DefaultPosition.static ExecutableElementgetGetContentMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)static ExecutableElementgetGetPreviewMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)static StringgetInterceptMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)static StringgetIsDirtyMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)Get the method name annotated with@IsDirty.static booleangetIsElement(TypeMirror type, ProcessingEnvironment processingEnvironment)Check whether the provided type extends IsElement.static booleangetIsPopup(TypeElement classElement, ProcessingEnvironment processingEnvironment)Check whether the provided type extends PopupPanel.static booleangetIsWidget(TypeElement classElement, ProcessingEnvironment processingEnvironment)Check whether the provided type extends IsWidget.static StringgetMenuBarMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)Get the method name annotated with@WorkbenchMenu.static StringgetOnCloseMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)Get the method name annotated with@OnClose.static StringgetOnContextAttachPanelDefinitionMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)static StringgetOnFocusMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)Get the method name annotated with@OnFocus.static StringgetOnLostFocusMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)Get the method name annotated with@OnLostFocus.static StringgetOnMayCloseMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)Get the method name annotated with@OnMayClose.static StringgetOnOpenMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)Get the method name annotated with@OnOpen.static StringgetOnSaveMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)Get the method name annotated with@OnSave.static StringgetOnShutdownMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)Get the method name annotated with@OnShutdown.static ExecutableElementgetOnStartupMethodForEditors(TypeElement classElement, ProcessingEnvironment processingEnvironment)Finds the@OnStartupmethod suitable for@WorkbenchEditorclasses.static ExecutableElementgetOnStartupMethodForNonEditors(TypeElement classElement, ProcessingEnvironment processingEnvironment)Finds the@OnStartupmethod suitable for workbench classes that are not@WorkbenchEditor.static StringgetOwningPerspectivePlaceRequest(TypeElement screenOrEditorClass, ProcessingEnvironment processingEnvironment)Returns the identifier (PlaceRequest ID) of the perspective that owns the given part.static StringgetPerspectiveMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)Get the method name annotated with@Perspective.static StringgetPopupMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)Get the method name annotated with@WorkbenchPartView.static NamegetQualifiedName(AnnotationMirror annotation)static ExecutableElementgetSetContentMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)static StringgetSplashFilterMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)static StringgetTitleMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)Get the method name annotated with@WorkbenchPartTitle.static ExecutableElementgetTitleWidgetMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)Get the method name annotated with@WorkbenchPartTitleDecoration.static StringgetToolBarMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)Get the method name annotated with@WorkbenchToolBar.static ExecutableElementgetValidateMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)static ExecutableElementgetWidgetMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)Get the method name annotated with@WorkbenchPartView.static booleanhasPresenterInitMethod(TypeElement classElement, ProcessingEnvironment processingEnvironment, ExecutableElement getWidgetMethod)
-
-
-
Method Detail
-
getOnStartupMethodForNonEditors
public static ExecutableElement getOnStartupMethodForNonEditors(TypeElement classElement, ProcessingEnvironment processingEnvironment)
Finds the@OnStartupmethod suitable for workbench classes that are not@WorkbenchEditor. The method must be public, non-static, have a return-type of void and either take zero parameters or one parameter of typePlaceRequest. If no such method is found, returns null. If methods annotated with@OnStartupare found but they do not satisfy all the requirements, they are marked with errors explaining the problem.
-
getSetContentMethodName
public static ExecutableElement getSetContentMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)
-
getGetContentMethodName
public static ExecutableElement getGetContentMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)
-
getGetPreviewMethodName
public static ExecutableElement getGetPreviewMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)
-
getOnStartupMethodForEditors
public static ExecutableElement getOnStartupMethodForEditors(TypeElement classElement, ProcessingEnvironment processingEnvironment)
Finds the@OnStartupmethod suitable for@WorkbenchEditorclasses. The method must be public, non-static, have a return-type of void and either take one parameter of typePathor two parameters of type(Path, PlaceRequest). If no such method is found, returns null. If methods annotated with@OnStartupare found but they do not satisfy all the requirements, they are marked with errors explaining the problem.
-
getOnContextAttachPanelDefinitionMethodName
public static String getOnContextAttachPanelDefinitionMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment) throws GenerationException
- Throws:
GenerationException
-
getOnMayCloseMethodName
public static String getOnMayCloseMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment) throws GenerationException
Get the method name annotated with@OnMayClose. The method must be public, non-static, have a return-type of void and take zero parameters.- Parameters:
classElement-processingEnvironment-- Returns:
- null if none found
- Throws:
GenerationException
-
getOnCloseMethodName
public static String getOnCloseMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment) throws GenerationException
Get the method name annotated with@OnClose. The method must be public, non-static, have a return-type of void and take zero parameters.- Parameters:
classElement-processingEnvironment-- Returns:
- null if none found
- Throws:
GenerationException
-
getOnShutdownMethodName
public static String getOnShutdownMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment) throws GenerationException
Get the method name annotated with@OnShutdown. The method must be public, non-static, have a return-type of void and take zero parameters.- Parameters:
classElement-processingEnvironment-- Returns:
- null if none found
- Throws:
GenerationException
-
getOnOpenMethodName
public static String getOnOpenMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment) throws GenerationException
Get the method name annotated with@OnOpen. The method must be public, non-static, have a return-type of void and take zero parameters.- Parameters:
classElement-processingEnvironment-- Returns:
- null if none found
- Throws:
GenerationException
-
getOnLostFocusMethodName
public static String getOnLostFocusMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment) throws GenerationException
Get the method name annotated with@OnLostFocus. The method must be public, non-static, have a return-type of void and take zero parameters.- Parameters:
classElement-processingEnvironment-- Returns:
- null if none found
- Throws:
GenerationException
-
getOnFocusMethodName
public static String getOnFocusMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment) throws GenerationException
Get the method name annotated with@OnFocus. The method must be public, non-static, have a return-type of void and take zero parameters.- Parameters:
classElement-processingEnvironment-- Returns:
- null if none found
- Throws:
GenerationException
-
getDefaultPositionMethodName
public static String getDefaultPositionMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment) throws GenerationException
Get the method name annotated with@DefaultPosition. The method must be public, non-static, have a return-type of void and take zero parameters.- Parameters:
classElement-processingEnvironment-- Returns:
- null if none found
- Throws:
GenerationException
-
getTitleMethodName
public static String getTitleMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment) throws GenerationException
Get the method name annotated with@WorkbenchPartTitle. The method must be public, non-static, have a return-type of java.lang.String and take zero parameters.- Parameters:
classElement-processingEnvironment-- Returns:
- null if none found
- Throws:
GenerationException
-
getContextIdMethodName
public static String getContextIdMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment) throws GenerationException
- Throws:
GenerationException
-
getTitleWidgetMethodName
public static ExecutableElement getTitleWidgetMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment) throws GenerationException
Get the method name annotated with@WorkbenchPartTitleDecoration. The method must be public, non-static, have a return-type of com.google.gwt.user.client.ui.IsWidget and take zero parameters.- Parameters:
classElement-processingEnvironment-- Returns:
- null if none found
- Throws:
GenerationException
-
getWidgetMethodName
public static ExecutableElement getWidgetMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment) throws GenerationException
Get the method name annotated with@WorkbenchPartView. The method must be public, non-static, have a return-type of IsWidget and take zero parameters.- Parameters:
classElement-processingEnvironment-- Returns:
- null if none found
- Throws:
GenerationException
-
getIsWidget
public static boolean getIsWidget(TypeElement classElement, ProcessingEnvironment processingEnvironment)
Check whether the provided type extends IsWidget.- Parameters:
classElement-processingEnvironment-- Returns:
-
getIsElement
public static boolean getIsElement(TypeMirror type, ProcessingEnvironment processingEnvironment)
Check whether the provided type extends IsElement.- Parameters:
type-processingEnvironment-- Returns:
-
hasPresenterInitMethod
public static boolean hasPresenterInitMethod(TypeElement classElement, ProcessingEnvironment processingEnvironment, ExecutableElement getWidgetMethod)
-
getPopupMethodName
public static String getPopupMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment) throws GenerationException
Get the method name annotated with@WorkbenchPartView. The method must be public, non-static, have a return-type of PopupPanel and take zero parameters.- Parameters:
classElement-processingEnvironment-- Returns:
- null if none found
- Throws:
GenerationException
-
getIsPopup
public static boolean getIsPopup(TypeElement classElement, ProcessingEnvironment processingEnvironment)
Check whether the provided type extends PopupPanel.- Parameters:
classElement-processingEnvironment-- Returns:
-
getIsDirtyMethodName
public static String getIsDirtyMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment) throws GenerationException
Get the method name annotated with@IsDirty. The method must be public, non-static, have a return-type of void and take zero parameters.- Parameters:
classElement-processingEnvironment-- Returns:
- null if none found
- Throws:
GenerationException
-
getOnSaveMethodName
public static String getOnSaveMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment) throws GenerationException
Get the method name annotated with@OnSave. The method must be public, non-static, have a return-type of void and take zero parameters.- Parameters:
classElement-processingEnvironment-- Returns:
- null if none found
- Throws:
GenerationException
-
getMenuBarMethodName
public static String getMenuBarMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment) throws GenerationException
Get the method name annotated with@WorkbenchMenu. The method must be public, non-static, have a return-type of WorkbenchMenuBar and take zero parameters.- Parameters:
classElement-processingEnvironment-- Returns:
- null if none found
- Throws:
GenerationException
-
getToolBarMethodName
public static String getToolBarMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment) throws GenerationException
Get the method name annotated with@WorkbenchToolBar. The method must be public, non-static, have a return-type of WorkbenchToolBar and take zero parameters.- Parameters:
classElement-processingEnvironment-- Returns:
- null if none found
- Throws:
GenerationException
-
getPerspectiveMethodName
public static String getPerspectiveMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment) throws GenerationException
Get the method name annotated with@Perspective. The method must be public, non-static, have a return-type of PerspectiveDefinition and take zero parameters.- Parameters:
classElement-processingEnvironment-- Returns:
- null if none found
- Throws:
GenerationException
-
getSplashFilterMethodName
public static String getSplashFilterMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment) throws GenerationException
- Throws:
GenerationException
-
getBodyHeightMethodName
public static String getBodyHeightMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment) throws GenerationException
- Throws:
GenerationException
-
getInterceptMethodName
public static String getInterceptMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment) throws GenerationException
- Throws:
GenerationException
-
getBeanActivatorClassName
public static String getBeanActivatorClassName(TypeElement classElement, ProcessingEnvironment processingEnvironment)
-
getOwningPerspectivePlaceRequest
public static String getOwningPerspectivePlaceRequest(TypeElement screenOrEditorClass, ProcessingEnvironment processingEnvironment) throws GenerationException
Returns the identifier (PlaceRequest ID) of the perspective that owns the given part.- Parameters:
screenOrEditorClass- a type annotated with either@WorkbenchScreenor@WorkbenchEditor. Not null.processingEnvironment- the current annotation processing environment.- Returns:
- Throws:
GenerationException- if the owningPerspective parameter is present, but points to something other than a@WorkbenchPerspectiveclass.
-
getAnnotation
public static AnnotationMirror getAnnotation(Elements elementUtils, Element annotationTarget, String annotationName)
-
getQualifiedName
public static Name getQualifiedName(AnnotationMirror annotation)
-
extractValue
public static Collection<String> extractValue(AnnotationValue value)
Provides a uniform way of working with single- and multi-valued AnnotationValue objects.- Returns:
- the annotation values as strings. For multi-valued annotation params, the collection's iteration order matches the order the values appeared in the source code. Single-valued params are wrapped in a single-element collection. In either case, don't attempt to modify the returned collection.
-
extractAnnotationsFromAnnotation
public static List<AnnotationMirror> extractAnnotationsFromAnnotation(Elements elementUtils, Element element, String annotationName, String paramName)
Pulls nested annotations out of the annotation that contains them.- Parameters:
elementUtils- the current Elements object from this round of annotation processing.element- The element targeted by the containing annotation.annotationName- The containing annotation's fully-qualified name.paramName- The name of the parameter on the containing annotation. The parameter's type must be an array of annotations.
-
formatAssociatedResources
public static String formatAssociatedResources(Collection<String> resourceTypes)
-
debugLoggingEnabled
public static boolean debugLoggingEnabled()
-
extractAnnotationStringValue
public static String extractAnnotationStringValue(Elements elementUtils, AnnotationMirror annotation, CharSequence paramName)
-
extractAnnotationPropertyValue
public static AnnotationValue extractAnnotationPropertyValue(Elements elementUtils, AnnotationMirror annotation, CharSequence annotationProperty)
-
getAllQualifiersDeclarationFromType
public static List<String> getAllQualifiersDeclarationFromType(TypeElement element)
This method builds a list of all qualifier annotations source-code declaration that annotates the passed element.- Parameters:
element-TypeElementwhich will be scanned for qualifier annotations.- Returns:
- A list of the annotations source-code declarations.
-
getValidateMethodName
public static ExecutableElement getValidateMethodName(TypeElement classElement, ProcessingEnvironment processingEnvironment)
-
-