You're viewing an older version of Vaadin JavaDoc. Please see version 24.7.0 for the latest.
com.vaadin.copilot.javarewriter.

Record Class JavaComponent

java.lang.Object
java.lang.Record
com.vaadin.copilot.javarewriter.JavaComponent

Record Components:

tag - the tag of the component, used to determine the Java class

className - the class name if known, or null to use the tag to look up the class

props - the properties of the component

children - the child components

public record JavaComponent(String tag, String className, Map<String,Object> props, List<JavaComponent> children) extends Record

Represents a Java component to be added to the source code.

  • Constructor Details

    • JavaComponent

      public JavaComponent(String tag, String className, Map<String,Object> props, List<JavaComponent> children)

      Creates an instance of a JavaComponent record class.

      Parameters:

      tag - the value for the tag record component

      className - the value for the className record component

      props - the value for the props record component

      children - the value for the children record component

  • Method Details

    • withTag

      public JavaComponent withTag(String tag)
    • componentFromJson

      public static JavaComponent componentFromJson(elemental.json.JsonObject json)

      Creates a new JavaComponent instance from a JSON object.

      Parameters:

      json - the JSON object

      Returns:

      the JavaComponent instance

    • componentsFromJson

      public static List<JavaComponent> componentsFromJson(elemental.json.JsonArray template)

      Creates a new JavaComponent instance from a JSON array.

      Parameters:

      template - the JSON array

      Returns:

      the JavaComponent instances

    • getItemsFromProperty

      public List<Map<String,Object>> getItemsFromProperty()

      return items of a component if they exist as a property

      Returns:

      the tag

    • toString

      public final String toString()

      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.

      Specified by:

      toString in class Record

      Returns:

      a string representation of this object

    • hashCode

      public final int hashCode()

      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.

      Specified by:

      hashCode in class Record

      Returns:

      a hash code value for this object

    • equals

      public final boolean equals(Object o)

      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).

      Specified by:

      equals in class Record

      Parameters:

      o - the object with which to compare

      Returns:

      true if this object is the same as the o argument; false otherwise.

    • tag

      public String tag()

      Returns the value of the tag record component.

      Returns:

      the value of the tag record component

    • className

      public String className()

      Returns the value of the className record component.

      Returns:

      the value of the className record component

    • props

      public Map<String,Object> props()

      Returns the value of the props record component.

      Returns:

      the value of the props record component

    • children

      public List<JavaComponent> children()

      Returns the value of the children record component.

      Returns:

      the value of the children record component