Class SWIPrologSolution<S>

  • Type Parameters:
    S - the type of the values of the variable that is of special interest
    All Implemented Interfaces:
    Iterable<S>

    public class SWIPrologSolution<S>
    extends Solution<S>
    The Solution class is responsible for traversing through the solutions of a query.
    • Method Detail

      • isSuccess

        public boolean isSuccess()
        Description copied from class: Solution
        Returns whether there exists a solution or not. Does not depend on the state of the traversal, only one solution should exist.
        Specified by:
        isSuccess in class Solution<S>
        Returns:
        true if the goal can be satisfied, otherwise false
      • get

        public <A> A get​(String variable)
        Description copied from class: Solution
        Returns the value of the given variable bound to by the first solution of the goal.
        Specified by:
        get in class Solution<S>
        Type Parameters:
        A - the type of the value
        Parameters:
        variable - the name of the variable
        Returns:
        the value bound to the variable
      • get

        public <A> A get​(String variable,
                         Class<A> type)
        Description copied from class: Solution
        Returns the value of the given variable bound by the first solution. The required type of the value can be specified explicitly. This is useful when not the default type is desired.
        Specified by:
        get in class Solution<S>
        Type Parameters:
        A - the type of the value
        Parameters:
        variable - the name of the variable
        type - the type which the value should be converted to
        Returns:
        the value bound to the variable
      • collect

        public void collect​(Collection<?>... collections)
        Description copied from class: Solution
        Collects the values of the variables into the given collections.
        Specified by:
        collect in class Solution<S>
        Parameters:
        collections - the collections which will store the solutions
      • toLists

        public List<?>[] toLists()
        Description copied from class: Solution
        Collects the values of the variables into a List array.
        Specified by:
        toLists in class Solution<S>
        Returns:
        a list array containing the values of the variables
      • fetch

        protected boolean fetch()
        Description copied from class: Solution
        Fetches the next solution if there is one.
        Specified by:
        fetch in class Solution<S>
        Returns:
        true if there was another solution, otherwise false