Record Class StringInterpolationPart
java.lang.Object
java.lang.Record
org.ek9lang.compiler.ir.data.StringInterpolationPart
- Record Components:
type- The part type (LITERAL or VARIABLE)value- For LITERAL: the text content; for VARIABLE: the variable nameoriginalType- For VARIABLE: the type before $ conversion (null for LITERAL)
public record StringInterpolationPart(StringInterpolationPart.PartType type, String value, String originalType)
extends Record
Represents a single part of an interpolated string.
Parts are either:
- LITERAL - Fixed text, value contains the literal string
- VARIABLE - String variable reference, value contains variable name
For VARIABLE parts, originalType records the type before String conversion. This metadata supports debugging, analysis, and potential Phase 12 optimizations (e.g., reusing a previously converted String if the source hasn't been mutated).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumType of interpolation part. -
Constructor Summary
ConstructorsConstructorDescriptionStringInterpolationPart(StringInterpolationPart.PartType type, String value, String originalType) Creates an instance of aStringInterpolationPartrecord 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.booleanCheck if this is a literal part.booleanCheck if this is a variable part.static StringInterpolationPartCreate a literal text part.Returns the value of theoriginalTyperecord component.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.value()Returns the value of thevaluerecord component.static StringInterpolationPartCreate a variable reference part.
-
Constructor Details
-
StringInterpolationPart
public StringInterpolationPart(StringInterpolationPart.PartType type, String value, String originalType) Creates an instance of aStringInterpolationPartrecord class.- Parameters:
type- the value for thetyperecord componentvalue- the value for thevaluerecord componentoriginalType- the value for theoriginalTyperecord component
-
-
Method Details
-
literal
Create a literal text part.- Parameters:
text- The literal text content- Returns:
- A new LITERAL part
-
variable
Create a variable reference part.- Parameters:
variableName- The name of the String variableoriginalType- The type before conversion (for analysis/debugging)- Returns:
- A new VARIABLE part
-
isLiteral
public boolean isLiteral()Check if this is a literal part.- Returns:
- true if this part contains literal text
-
isVariable
public boolean isVariable()Check if this is a variable part.- Returns:
- true if this part references a String variable
-
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). -
type
-
value
-
originalType
Returns the value of theoriginalTyperecord component.- Returns:
- the value of the
originalTyperecord component
-