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
ConstructorsConstructorDescriptionSerdeSourceGenSwitches(io.micronaut.inject.visitor.VisitorContext.Language language) Creates an instance of aSerdeSourceGenSwitchesrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.io.micronaut.inject.visitor.VisitorContext.Languagelanguage()Returns the value of thelanguagerecord component.io.micronaut.sourcegen.model.StatementDefstatementSwitch(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 StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
SerdeSourceGenSwitches
public SerdeSourceGenSwitches(io.micronaut.inject.visitor.VisitorContext.Language language) Creates an instance of aSerdeSourceGenSwitchesrecord class.- Parameters:
language- the value for thelanguagerecord 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 valuetype- The type of the value, a primitive or an enumlocalName- The name of the local the Groovy source stores a value that is not a variable incases- The statements by the matched constant- Returns:
- The switch statement
-
toString
-
hashCode
-
equals
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 withObjects::equals(Object,Object). -
language
-