java.lang.Object
java.lang.Record
org.klojang.templates.VariableOccurrence
- Record Components:
name
- the name of the variablevarGroup
- anOptional
containing the variable group corresponding to the group name prefix (as in~%myVarGroup:foo%
), or an emptyOptional
if there was no group name prefixplaceholder
- anOptional
containing the placeholder value for this occurrence (as in<!-- ~%firstName% -->John<!--%-->
), or an emptyOptional
if no placeholder was specified. (SeeVarGroup.DEF
andRegex.REGEX_CMT_VARIABLE
.)position
- the position (index) of this occurrence within the template
public record VariableOccurrence(String name, Optional<VarGroup> varGroup, Optional<String> placeholder, int position)
extends Record
Represents a concrete occurrence of a variable within a template. Variable names
may occur multiple times within the same template. A
VariableOccurrence
captures the information associated with a single occurrence.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.name()
Returns the value of thename
record component.Returns the value of theplaceholder
record component.int
position()
Returns the value of theposition
record component.final String
toString()
Returns a string representation of this record class.varGroup()
Returns the value of thevarGroup
record component.
-
Constructor Details
-
VariableOccurrence
public VariableOccurrence(String name, Optional<VarGroup> varGroup, Optional<String> placeholder, int position) Creates an instance of aVariableOccurrence
record class.- Parameters:
name
- the value for thename
record componentvarGroup
- the value for thevarGroup
record componentplaceholder
- the value for theplaceholder
record componentposition
- the value for theposition
record component
-
-
Method Details
-
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. -
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. -
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. Reference components are compared withObjects::equals(Object,Object)
; primitive components are compared with '=='. -
name
Returns the value of thename
record component.- Returns:
- the value of the
name
record component
-
varGroup
Returns the value of thevarGroup
record component.- Returns:
- the value of the
varGroup
record component
-
placeholder
Returns the value of theplaceholder
record component.- Returns:
- the value of the
placeholder
record component
-
position
public int position()Returns the value of theposition
record component.- Returns:
- the value of the
position
record component
-