java.lang.Object
java.lang.Record
io.jenetics.ext.grammar.Cfg.Rule<T>
- Type Parameters:
T
- the terminal symbol value type
- All Implemented Interfaces:
Cfg.Annotatable<T>
public static record Cfg.Rule<T>(Cfg.NonTerminal<T> start, List<Cfg.Expression<T>> alternatives, Object annotation)
extends Record
implements Cfg.Annotatable<T>
Represents a production rule of the grammar (
R
).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Builder class for building CFG rules. -
Constructor Summary
ConstructorsConstructorDescriptionRule
(Cfg.NonTerminal<T> start, List<Cfg.Expression<T>> alternatives) Rule
(Cfg.NonTerminal<T> start, List<Cfg.Expression<T>> alternatives, Object annotation) Creates a new rule object. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thealternatives
record component.Returns the value of theannotation
record component.Create a new copy of the CFG element, with the givenannotation
.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.start()
Returns the value of thestart
record component.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
Rule
Creates a new rule object.- Parameters:
start
- the start symbol of the rulealternatives
- the list of alternative rule expressions- Throws:
IllegalArgumentException
- if the given list ofalternatives
is emptyNullPointerException
- if one of the arguments isnull
-
Rule
-
-
Method Details
-
at
Description copied from interface:Cfg.Annotatable
Create a new copy of the CFG element, with the givenannotation
.- Specified by:
at
in interfaceCfg.Annotatable<T>
- Parameters:
annotation
- the annotation of the newly created element, may benull
- Returns:
- a copy of the element with the given
annotation
-
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
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. All components in this record class are compared withObjects::equals(Object,Object)
. -
start
Returns the value of thestart
record component.- Returns:
- the value of the
start
record component
-
alternatives
Returns the value of thealternatives
record component.- Returns:
- the value of the
alternatives
record component
-
annotation
Returns the value of theannotation
record component.- Specified by:
annotation
in interfaceCfg.Annotatable<T>
- Returns:
- the value of the
annotation
record component
-