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 classBuilder 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 thealternativesrecord component.Returns the value of theannotationrecord component.Create a new copy of the CFG element, with the givenannotation.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.start()Returns the value of thestartrecord component.final StringtoString()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 ofalternativesis emptyNullPointerException- if one of the arguments isnull
-
Rule
-
-
Method Details
-
at
Description copied from interface:Cfg.AnnotatableCreate a new copy of the CFG element, with the givenannotation.- Specified by:
atin 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 thestartrecord component.- Returns:
- the value of the
startrecord component
-
alternatives
Returns the value of thealternativesrecord component.- Returns:
- the value of the
alternativesrecord component
-
annotation
Returns the value of theannotationrecord component.- Specified by:
annotationin interfaceCfg.Annotatable<T>- Returns:
- the value of the
annotationrecord component
-