Record Class SubTypeWriter.SubTemplate

java.lang.Object
java.lang.Record
io.avaje.validation.generator.SubTypeWriter.SubTemplate
Enclosing class:
SubTypeWriter

@JStache(template="package {{packageName}};\n\n{{#imports}}\nimport {{.}};\n{{/imports}}\n\n@Generated(\"avaje-validation-generator\")\npublic class {{shortName}}ValidationAdapter implements ValidationAdapter<{{shortType}}> {\n\n{{#subtypes}}\n private final ValidationAdapter<{{.}}> subAdapter{{@index}};\n{{/subtypes}}\n\n public {{shortName}}ValidationAdapter(ValidationContext ctx) {\n{{#subtypes}}\n this.subAdapter{{@index}} = ctx.adapter({{.}}.class);\n{{/subtypes}}\n }\n\n @Override\n public boolean validate({{shortType}} value, ValidationRequest request, String field) {\n{{#switchValid}}\n return switch(value) {\n case null -> true;\n {{#subtypes}}\n case {{.}} val -> subAdapter{{@index}}.validate(val, request, field);\n {{/subtypes}}\n {{^sealed}}\n default -> true;\n {{/sealed}}\n };\n{{/switchValid}}\n{{^switchValid}}\n{{#subtypes}}\n if (value instanceof {{.}} val) {\n return subAdapter{{@index}}.validate(val, request, field);\n }\n{{/subtypes}}\n return true;\n{{/switchValid}}\n }\n}\n") public static record SubTypeWriter.SubTemplate(String packageName, Set<String> imports, String shortName, String shortType, List<String> subtypes, boolean switchValid, boolean sealed) extends Record
  • Constructor Summary

    Constructors
    Constructor
    Description
    SubTemplate(String packageName, Set<String> imports, String shortName, String shortType, List<String> subtypes, boolean switchValid, boolean sealed)
    Creates an instance of a SubTemplate record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    Returns the value of the imports record component.
    Returns the value of the packageName record component.
    boolean
    Returns the value of the sealed record component.
    Returns the value of the shortName record component.
    Returns the value of the shortType record component.
    Returns the value of the subtypes record component.
    boolean
    Returns the value of the switchValid record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SubTemplate

      public SubTemplate(String packageName, Set<String> imports, String shortName, String shortType, List<String> subtypes, boolean switchValid, boolean sealed)
      Creates an instance of a SubTemplate record class.
      Parameters:
      packageName - the value for the packageName record component
      imports - the value for the imports record component
      shortName - the value for the shortName record component
      shortType - the value for the shortType record component
      subtypes - the value for the subtypes record component
      switchValid - the value for the switchValid record component
      sealed - the value for the sealed 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • packageName

      public String packageName()
      Returns the value of the packageName record component.
      Returns:
      the value of the packageName record component
    • imports

      public Set<String> imports()
      Returns the value of the imports record component.
      Returns:
      the value of the imports record component
    • shortName

      public String shortName()
      Returns the value of the shortName record component.
      Returns:
      the value of the shortName record component
    • shortType

      public String shortType()
      Returns the value of the shortType record component.
      Returns:
      the value of the shortType record component
    • subtypes

      public List<String> subtypes()
      Returns the value of the subtypes record component.
      Returns:
      the value of the subtypes record component
    • switchValid

      public boolean switchValid()
      Returns the value of the switchValid record component.
      Returns:
      the value of the switchValid record component
    • sealed

      public boolean sealed()
      Returns the value of the sealed record component.
      Returns:
      the value of the sealed record component