Class FlowComponentQuirks

java.lang.Object
com.vaadin.copilot.javarewriter.FlowComponentQuirks

public final class FlowComponentQuirks extends Object
This class contains hacks related to Flow components and how they work.
  • Field Details

  • Method Details

    • getClassForComponent

      public static String getClassForComponent(JavaComponent javaComponent)
      Returns the Java class name for a given HTML tag.
      Parameters:
      javaComponent - the java Component
      Returns:
      the Java class name
    • getClassHierarchy

      public static List<String> getClassHierarchy(JavaComponent javaComponent)
    • 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 type
      prop - the property name
      value - the property value
      Returns:
      the rewritten value or the original value if no rewriting is needed
    • convertReactPropertyToJavaSetter

      public static String convertReactPropertyToJavaSetter(String property, Class<?> type)
      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 name
      type - the component type
      Returns:
      the Java setter method name or null if no mapping is found
    • getInnerTextProperty

      public static String getInnerTextProperty(Class<?> componentType)
    • isInvertedBoolean

      public static boolean isInvertedBoolean(String property, Class<?> type)
    • childrenGeneratesData

      public static boolean childrenGeneratesData(JavaComponent parent, JavaComponent child)
      Returns true if child is not a component but an item that is used in DataProvider.
      Parameters:
      parent - Parent component
      child - Child definition
      Returns:
      true if it is, false otherwise.
    • hasSetItemsProps

      public static boolean hasSetItemsProps(JavaComponent component)
      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

      public static boolean hasSetItemsMethod(JavaComponent component)
    • skipProps

      public static boolean skipProps(JavaComponent component, String propKey)
    • getMethodCallChildren

      public static List<JavaComponent> getMethodCallChildren(JavaComponent javaComponent)
      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

      public static String getSetterNameFromComponent(JavaComponent child)
      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 JavaComponent
      owner - The owner object
      dataEntityRecordName - The name of the data entity record
      Returns:
      The MethodCallExpr
    • isGridColumnDefinition

      public static boolean isGridColumnDefinition(JavaComponent component)
      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

      public static boolean isGridTreeColumnDefinition(JavaComponent component)
      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

      public static boolean isGridColumnAttribute(JavaComponent component)
      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

      public static boolean isTabSheetDefinition(JavaComponent component)
    • 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 JavaComponent
      parentSetterName - The name of the parent setter method
      setterName - The name of the setter method
      value - The value of the property
      owner - The owner object where the property will be set
      insertionPoint - The insertion point where the expression will be added to add more required expressions different to the actual setter if needed
      Returns: