Package com.vaadin.copilot.javarewriter
Class FlowComponentQuirks
java.lang.Object
com.vaadin.copilot.javarewriter.FlowComponentQuirks
This class contains hacks related to Flow components and how they work.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanchildrenGeneratesData(JavaComponent parent, JavaComponent child) Returns true if child is not a component but an item that is used in DataProvider.static ObjectcomponentSpecificValueMapping(Class<?> componentType, String prop, Object value) Rewrites the value of a property for a specific component type.static StringconvertReactPropertyToJavaSetter(String property, Class<?> type) Converts a React property name to a Java setter method name.static StringgetClassForComponent(JavaComponent javaComponent) Returns the Java class name for a given HTML tag.getClassHierarchy(JavaComponent javaComponent) static StringgetInnerTextProperty(Class<?> componentType) static List<JavaComponent> getMethodCallChildren(JavaComponent javaComponent) Returns the list of children of the given JavaComponent that should be added as method callsstatic List<com.github.javaparser.ast.expr.MethodCallExpr> getMethodCallExprFromComponent(com.github.javaparser.ast.CompilationUnit compilationUnit, JavaComponent child, com.github.javaparser.ast.expr.Expression owner, String dataEntityRecordName) Returns the MethodCallExpr to be added to the owner object for the given JavaComponentstatic com.github.javaparser.ast.expr.ExpressiongetPropertySetExpression(JavaComponent javaComponent, String parentSetterName, String setterName, Object value, com.github.javaparser.ast.expr.Expression owner, InsertionPoint insertionPoint) Returns the expression to be used to set a property in a JavaComponent.static StringReturns the name of the setter method to be called on the owner object for the given JavaComponentstatic booleanhasSetItemsMethod(JavaComponent component) static booleanhasSetItemsProps(JavaComponent component) Checks the given component has items property and supported.static booleanisGridColumnAttribute(JavaComponent component) Returns true when the java component indicates a Grid attribute according to Hilla React template.static booleanisGridColumnDefinition(JavaComponent component) Returns true when the java component indicates a Grid column definition according to Hilla React template.static booleanisGridTreeColumnDefinition(JavaComponent component) Returns true when the java component indicates a Tree Grid column definition according to Hilla React template.static booleanisInvertedBoolean(String property, Class<?> type) static booleanisTabSheetDefinition(JavaComponent component) static voidmenuBarInsertItemsPropsToAddItem(JavaComponent javaComponent, InsertionPoint insertionPoint, com.github.javaparser.ast.expr.Expression owner, com.github.javaparser.ast.expr.Expression parent, String setterName, Object value, boolean submenu) Specific method to handle MenuBar items property.static booleanskipProps(JavaComponent component, String propKey)
-
Field Details
-
HAS_PREFIX_QUALIFIED_CLASS_NAME
- See Also:
-
HAS_SUFFIX_QUALIFIED_CLASS_NAME
- See Also:
-
HAS_COMPONENTS_QUALIFIED_CLASS_NAME
- See Also:
-
CHART_TYPE
- See Also:
-
-
Method Details
-
getClassForComponent
Returns the Java class name for a given HTML tag.- Parameters:
javaComponent- the java Component- Returns:
- the Java class name
-
getClassHierarchy
-
componentSpecificValueMapping
public static Object componentSpecificValueMapping(Class<?> componentType, String prop, Object value) Rewrites the value of a property for a specific component type.- Parameters:
componentType- the component typeprop- the property namevalue- the property value- Returns:
- the rewritten value or the original value if no rewriting is needed
-
convertReactPropertyToJavaSetter
Converts a React property name to a Java setter method name.Used to map React properties to Java setters when the react property API does not match the Java API.
- Parameters:
property- the property nametype- the component type- Returns:
- the Java setter method name or
nullif no mapping is found
-
getInnerTextProperty
-
isInvertedBoolean
-
childrenGeneratesData
Returns true if child is not a component but an item that is used in DataProvider.- Parameters:
parent- Parent componentchild- Child definition- Returns:
- true if it is, false otherwise.
-
hasSetItemsProps
Checks the given component has items property and supported.- Parameters:
component- component which has tag and props.- Returns:
- true if component tag is listed in supported list and has items property, false otherwise.
-
hasSetItemsMethod
-
skipProps
-
getMethodCallChildren
Returns the list of children of the given JavaComponent that should be added as method calls- Parameters:
javaComponent- The JavaComponent- Returns:
- The list of children to be added as method calls
-
getSetterNameFromComponent
Returns the name of the setter method to be called on the owner object for the given JavaComponent- Parameters:
child- The JavaComponent- Returns:
- The name of the setter method
-
getMethodCallExprFromComponent
public static List<com.github.javaparser.ast.expr.MethodCallExpr> getMethodCallExprFromComponent(com.github.javaparser.ast.CompilationUnit compilationUnit, JavaComponent child, com.github.javaparser.ast.expr.Expression owner, String dataEntityRecordName) Returns the MethodCallExpr to be added to the owner object for the given JavaComponent- Parameters:
child- The JavaComponentowner- The owner objectdataEntityRecordName- The name of the data entity record- Returns:
- The MethodCallExpr
-
isGridColumnDefinition
Returns true when the java component indicates a Grid column definition according to Hilla React template. Grid column components are GridColumn, GridSortColumn and GridTreeColumn. If this component are present for columns defined for a Grid.- Parameters:
component- The JavaComponent- Returns:
- true if the component is a Grid column component, false otherwise
-
isGridTreeColumnDefinition
Returns true when the java component indicates a Tree Grid column definition according to Hilla React template. Tree Grid column attribute components is GridTreeColumn.- Parameters:
component- The JavaComponent- Returns:
- true if the component is a TreeGrid column attribute, false otherwise
-
isGridColumnAttribute
Returns true when the java component indicates a Grid attribute according to Hilla React template. Grid attribute components so far is GridSelectionColumn.- Parameters:
component- The JavaComponent- Returns:
- true if the component is a Grid attribute, false otherwise
-
isTabSheetDefinition
-
getPropertySetExpression
public static com.github.javaparser.ast.expr.Expression getPropertySetExpression(JavaComponent javaComponent, String parentSetterName, String setterName, Object value, com.github.javaparser.ast.expr.Expression owner, InsertionPoint insertionPoint) Returns the expression to be used to set a property in a JavaComponent. This method modifies the code adding everything required to set the property like intermediate variables or method calls.- Parameters:
javaComponent- The JavaComponentparentSetterName- The name of the parent setter methodsetterName- The name of the setter methodvalue- The value of the propertyowner- The owner object where the property will be setinsertionPoint- The insertion point where the expression will be added to add more required expressions different to the actual setter if needed- Returns:
-