Class DataQuery

  • All Implemented Interfaces:
    java.lang.Iterable<java.lang.String>

    public final class DataQuery
    extends java.lang.Object
    implements java.lang.Iterable<java.lang.String>
    Represents a query that can be done on views. Queries do not depend on their separator, it is just a way to construct them.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String asString​(char separator)
      Gets this query as a string separated by the given separator character.
      java.lang.String asString​(java.lang.String separator)
      Gets this query as a string separated by the given separator.
      boolean equals​(java.lang.Object obj)  
      void forEach​(java.util.function.Consumer<? super java.lang.String> action)  
      int hashCode()  
      java.util.Iterator<java.lang.String> iterator()  
      DataQuery last()
      Gets the last entry of this DataQuery.
      static DataQuery of()
      Gets an empty DataQuery.
      static DataQuery of​(char separator, java.lang.String path)
      Constructs a query using the given separator character and path.
      static DataQuery of​(java.lang.String... parts)
      Constructs a query using the given parts.
      static DataQuery of​(java.util.List<java.lang.String> parts)
      Constructs a query using the given parts.
      java.util.List<java.lang.String> parts()
      Gets the parts that make up this query.
      DataQuery pop()
      Returns a DataQuery where the last node is "popped" off.
      DataQuery popFirst()
      Returns a DataQuery where the first node is "popped" off.
      java.util.List<DataQuery> queryParts()
      Returns the parts of this query as individual queries.
      java.util.Spliterator<java.lang.String> spliterator()  
      DataQuery then​(java.lang.String that)
      Returns a new query that is made up of this query's parts followed by the given query.
      DataQuery then​(DataQuery that)
      Returns a new query that is made up of this query's parts followed by the given query's parts.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • of

        public static DataQuery of()
        Gets an empty DataQuery. This query is constant and never changes and therefor can be called multiple times returning the same instance.
        Returns:
        An empty data query
      • of

        public static DataQuery of​(char separator,
                                   java.lang.String path)
        Constructs a query using the given separator character and path.

        As an example, new DataQuery('/', "a/b/c") and new DataQuery('.', "a.b.c") represent the same path but are constructed using different separators.

        Parameters:
        separator - The separator
        path - The path
        Returns:
        The newly constructed DataQuery
      • of

        public static DataQuery of​(java.lang.String... parts)
        Constructs a query using the given parts.
        Parameters:
        parts - The parts
        Returns:
        The newly constructed DataQuery
      • of

        public static DataQuery of​(java.util.List<java.lang.String> parts)
        Constructs a query using the given parts.
        Parameters:
        parts - The parts
        Returns:
        The newly constructed DataQuery
      • parts

        public java.util.List<java.lang.String> parts()
        Gets the parts that make up this query. The returned list is immutable.
        Returns:
        The parts of this query
      • then

        public DataQuery then​(DataQuery that)
        Returns a new query that is made up of this query's parts followed by the given query's parts.
        Parameters:
        that - The given query to follow this one
        Returns:
        The constructed query
      • then

        public DataQuery then​(java.lang.String that)
        Returns a new query that is made up of this query's parts followed by the given query.
        Parameters:
        that - The given query to follow this one
        Returns:
        The constructed query
      • queryParts

        public java.util.List<DataQuery> queryParts()
        Returns the parts of this query as individual queries. The returned list is immutable.
        Returns:
        The constructed queries
      • pop

        public DataQuery pop()
        Returns a DataQuery where the last node is "popped" off. If this query is already the top level query, then the of() is returned.
        Returns:
        The next level query
      • popFirst

        public DataQuery popFirst()
        Returns a DataQuery where the first node is "popped" off. If this query is already the top level query, then the of() is returned.
        Returns:
        The next level query
      • last

        public DataQuery last()
        Gets the last entry of this DataQuery. If this query is a single entry query or an empty query, it returns itself.
        Returns:
        The last entry as a data query, if not already last
      • asString

        public java.lang.String asString​(java.lang.String separator)
        Gets this query as a string separated by the given separator.
        Parameters:
        separator - The separator
        Returns:
        This query as a string
      • asString

        public java.lang.String asString​(char separator)
        Gets this query as a string separated by the given separator character.
        Parameters:
        separator - The separator
        Returns:
        This query as a string
      • toString

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

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

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • iterator

        public java.util.Iterator<java.lang.String> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<java.lang.String>
      • forEach

        public void forEach​(java.util.function.Consumer<? super java.lang.String> action)
        Specified by:
        forEach in interface java.lang.Iterable<java.lang.String>
      • spliterator

        public java.util.Spliterator<java.lang.String> spliterator()
        Specified by:
        spliterator in interface java.lang.Iterable<java.lang.String>