Class JavaCopySource

java.lang.Object
com.vaadin.copilot.javarewriter.JavaCopySource
All Implemented Interfaces:
CopySource

public final class JavaCopySource extends Object implements CopySource
What a Java file says about a component being copied.

The behaviour copy has always had, moved behind CopySource so the same assembly serves another language. Nothing here changed.

  • Constructor Details

    • JavaCopySource

      public JavaCopySource(ComponentInfo componentInfo)
  • Method Details

    • componentInfo

      public ComponentInfo componentInfo()
      The resolved info, which the Java path also reports for diagnostics.
    • setsProperty

      public boolean setsProperty(String propertyKey)
      Description copied from interface: CopySource
      Whether the file actually sets this property.

      A live component reports a value for min and max whether or not anyone set them, so a copy would carry defaults the original never had and paste them as explicit calls.

      Specified by:
      setsProperty in interface CopySource
      Parameters:
      propertyKey - the JavaBean property name
      Returns:
      true if the source sets it
    • localVariableName

      public Optional<String> localVariableName()
      Specified by:
      localVariableName in interface CopySource
      Returns:
      the local variable the component is assigned to, if it is one
    • fieldVariableName

      public Optional<String> fieldVariableName()
      Specified by:
      fieldVariableName in interface CopySource
      Returns:
      the field the component is assigned to, if it is one
    • itemType

      public Optional<String> itemType()
      The bean type, where the component is a Grid and the source says what it is.

      Empty rather than fatal when it cannot be read. var grid = new Grid<>(Person.class) and a raw Grid grid = new Grid<>() both throw, and the caller's catch then discarded the whole metadata — so the paste lost the variable names and the original class as well, over a bean type. Raised in review of #9869.

      Specified by:
      itemType in interface CopySource
      Returns:
      the class name, or empty where the language cannot resolve it