Record Class UnionModel

java.lang.Object
java.lang.Record
com.vaadin.hilla.generator.model.UnionModel
Record Components:
javaClass - the fully qualified name of the Java class declaring the subtypes
subTypes - the types a value can be, in the order they are declared in

public record UnionModel(String javaClass, List<UnionModel.Member> subTypes) extends Record
The subtypes a polymorphic type is one of, which TypeScript can say as a union while Java says it as a hierarchy.

It is generated next to the type itself rather than instead of it: the type says what every one of the subtypes has, and the union says which of them a value can be, so that reading the discriminator of a value tells TypeScript which subtype it is looking at.

  • Constructor Details

    • UnionModel

      public UnionModel(String javaClass, List<UnionModel.Member> subTypes)
      Creates an instance of a UnionModel record class.
      Parameters:
      javaClass - the value for the javaClass record component
      subTypes - the value for the subTypes record component
  • Method Details

    • 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.
    • javaClass

      public String javaClass()
      Returns the value of the javaClass record component.
      Returns:
      the value of the javaClass record component
    • subTypes

      public List<UnionModel.Member> subTypes()
      Returns the value of the subTypes record component.
      Returns:
      the value of the subTypes record component