Record Class SerdeSourceGenSwitches

java.lang.Object
java.lang.Record
io.micronaut.serde.processor.sourcegen.SerdeSourceGenSwitches
Record Components:
language - The language of the generated source

@Internal public record SerdeSourceGenSwitches(io.micronaut.inject.visitor.VisitorContext.Language language) extends Record
Builds the statement switches of the generated serdes for the language the source is generated for.

The Java source backend renders a statement switch with case ... -> labels. Groovy only accepts those labels in a switch expression, so it parses such a switch as an expression and rejects the return statements the cases contain. The Groovy source therefore gets an if/else chain.

  • Constructor Summary

    Constructors
    Constructor
    Description
    SerdeSourceGenSwitches(io.micronaut.inject.visitor.VisitorContext.Language language)
    Creates an instance of a SerdeSourceGenSwitches 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.
    io.micronaut.inject.visitor.VisitorContext.Language
    Returns the value of the language record component.
    io.micronaut.sourcegen.model.StatementDef
    statementSwitch(io.micronaut.sourcegen.model.ExpressionDef value, io.micronaut.sourcegen.model.TypeDef type, String localName, Map<io.micronaut.sourcegen.model.ExpressionDef.Constant, io.micronaut.sourcegen.model.StatementDef> cases)
    Builds a statement that runs the case matching the value.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

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

    • SerdeSourceGenSwitches

      public SerdeSourceGenSwitches(io.micronaut.inject.visitor.VisitorContext.Language language)
      Creates an instance of a SerdeSourceGenSwitches record class.
      Parameters:
      language - the value for the language record component
  • Method Details

    • statementSwitch

      public io.micronaut.sourcegen.model.StatementDef statementSwitch(io.micronaut.sourcegen.model.ExpressionDef value, io.micronaut.sourcegen.model.TypeDef type, String localName, Map<io.micronaut.sourcegen.model.ExpressionDef.Constant, io.micronaut.sourcegen.model.StatementDef> cases)
      Builds a statement that runs the case matching the value.
      Parameters:
      value - The switched value
      type - The type of the value, a primitive or an enum
      localName - The name of the local the Groovy source stores a value that is not a variable in
      cases - The statements by the matched constant
      Returns:
      The switch statement
    • 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.
    • language

      public io.micronaut.inject.visitor.VisitorContext.Language language()
      Returns the value of the language record component.
      Returns:
      the value of the language record component