Class Rule


  • public class Rule
    extends TreeNode
    Instruction decoder rule node.
    • Constructor Summary

      Constructors 
      Constructor Description
      Rule​(java.lang.String name)
      Constructs a rule with one name.
      Rule​(java.util.List<java.lang.String> names)
      Constructs a rule with one or more names.
    • Constructor Detail

      • Rule

        public Rule​(java.util.List<java.lang.String> names)
        Constructs a rule with one or more names.
        Parameters:
        names - the list of all names of this rule
      • Rule

        public Rule​(java.lang.String name)
        Constructs a rule with one name.
        Parameters:
        name - the name of this rule
    • Method Detail

      • getNames

        public java.util.List<java.lang.String> getNames()
        Returns a list of all names of this rule.
        Returns:
        the list of names
      • hasOnlyOneName

        public boolean hasOnlyOneName()
        Returns true if this rule has only one name (not a list of names separated by commas).
        Returns:
        true if the rule has only one name, false otherwise
      • getMethodName

        public java.lang.String getMethodName()
        Returns a name of the method which should be generated for this rule.
        Returns:
        the method name
      • getFieldName

        public java.lang.String getFieldName​(java.lang.String ruleName)
        Returns a field name which should be generated for this rule (key).
        Parameters:
        ruleName - the particular rule name (one rule can have multiple names - keys)
        Returns:
        the name of a constant for the given key
      • getFieldName

        public java.lang.String getFieldName()
        Returns a field name of this rule (key). If the rule has more names, return the key of the root rule name.
        Returns:
        the name of a constant for the given key
      • getLabel

        public java.lang.String getLabel()
        Returns a human-readable label of this rule - a name or a list of names separated by commas.
        Returns:
        the label
      • isRoot

        public boolean isRoot()
        Determines if it is a root rule
        Returns:
        true if it is a root rule, false otherwise
      • getRootRuleName

        public java.lang.String getRootRuleName()
        Get root rule name (if this rule is root).
        Returns:
        root rule name if this rule is root; null otherwise
      • setRoot

        public Rule setRoot​(boolean isRoot,
                            java.lang.String rootRuleName)
        Sets if this rule is a root rule.
        Parameters:
        isRoot - true if it is a root rule, false otherwise
        rootRuleName - root rule name used in root rules declaration
        Returns:
        this
      • toString

        public java.lang.String toString()
        Returns a string representation of the object containing a rule name.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the string
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object