Class JoinPath

java.lang.Object
com.activeviam.database.api.schema.JoinPath
All Implemented Interfaces:
Serializable, Iterable<String>

public final class JoinPath extends Object implements Iterable<String>, Serializable
Represents the path from an initial table to another table that is reachable through table joins.

This representation simply contains the names of the joins to follow from one table to the other.

Because joins may not have unique names, the order of the path influences the target table reached when walking it.

Author:
ActiveViam
See Also:
  • Method Details

    • of

      public static JoinPath of(String... joinNames)
      Creates a path from the consecutive joins to follow.
    • of

      public static JoinPath of(List<String> joinNames)
      Creates a path from the consecutive joins to follow.
    • empty

      public static JoinPath empty()
      Creates the representation of a path not involving any relations.
    • asList

      public List<String> asList()
      Returns the path as a list of the relation names.

      The returned list is unmodifiable.

    • isEmpty

      public boolean isEmpty()
      Returns true when the path is empty (i.e. no relation).
    • append

      public JoinPath append(@NonNull @NonNull String join)
      Creates a new path starting with the current one and ending with the given join.
      Parameters:
      join - the name of a relation
      Returns:
      the concatenation of this path and the given join
    • getParent

      public JoinPath getParent()
      Gets the path to the previous table in the path.
    • startsWith

      public boolean startsWith(JoinPath prefix)
      Tests if this path of relations starts with another path.

      If the provided path is longer than this one, this returns false.

      Parameters:
      prefix - path to test as a prefix
    • iterator

      public Iterator<String> iterator()
      Returns an iterator over the joins.
      Specified by:
      iterator in interface Iterable<String>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      Overrides:
      toString in class Object