Class PredicateKey

  • All Implemented Interfaces:
    java.lang.Comparable<PredicateKey>

    public final class PredicateKey
    extends java.lang.Object
    implements java.lang.Comparable<PredicateKey>
    Represents the structure of a Term.

    Defines Terms by their name (functor) and number of arguments (arity). This "metadata" or "descriptor information" allows rules whose heads (consequences) share the same structure to be grouped together.

    As Atom and Structure are the only subclasses of Term that can be the head (consequent) of a rule they are the only subclasses of Term that PredicateKey is intended to describe.

    PredicateKeys are constant; their values cannot be changed after they are created.

    • Field Detail

      • PREDICATE_KEY_FUNCTOR

        private static final java.lang.String PREDICATE_KEY_FUNCTOR
        See Also:
        Constant Field Values
      • name

        private final java.lang.String name
      • numArgs

        private final int numArgs
    • Constructor Detail

      • PredicateKey

        public PredicateKey​(java.lang.String name,
                            int numArgs)
    • Method Detail

      • createFromNameAndArity

        public static PredicateKey createFromNameAndArity​(Term t)
        Parameters:
        t - must be a structure named / where the first argument is the name of the predicate to represent and the second (and final) argument is the arity.
      • getInvalidTypeExceptionMessage

        private static java.lang.String getInvalidTypeExceptionMessage​(Term t)
      • getName

        public java.lang.String getName()
      • getNumArgs

        public int getNumArgs()
      • toTerm

        public Term toTerm()
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - the reference object with which to compare.
        Returns:
        true if o is an instanceof PredicateKey and has the same name and number of arguments as this instance
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        Returns:
        name+"/"+numArgs
      • compareTo

        public int compareTo​(PredicateKey o)
        Ordered on name or, if names identical, number of arguments.
        Specified by:
        compareTo in interface java.lang.Comparable<PredicateKey>