Class Query.Builder

  • Enclosing class:
    Query

    public static class Query.Builder
    extends Object
    Facilitates the construction of Query instances. It allows for the step-by-step creation of these objects by providing methods for setting individual attributes. Input validations are performed at each build step.
    Since:
    1.7.0
    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • language

        public Query.Builder language​(@NotNull
                                      @NotNull Language language)
        Sets the programming language associated with the query.
        Parameters:
        language - the language associated with the query
        Returns:
        this builder
        Throws:
        NullPointerException - if the language is null
        UnsatisfiedLinkError - if the language was not linked to native code
        ABIVersionError - if the language ABI version is incompatible with requirements
      • patterns

        public Query.Builder patterns​(@NotNull
                                      @NotNull List<@NotNull String> patterns)
        Sets the collection of patterns that the Query will use to match nodes. This method will overwrite all the currently specified patterns.
        Parameters:
        patterns - a list of symbolic expression strings that make up the pattern
        Returns:
        this builder
        Throws:
        NullPointerException - if the pattern list is null or contains null elements
        Since:
        1.8.0
      • patterns

        public Query.Builder patterns​(@NotNull
                                      @NotNull String... patterns)
        Adds multiple symbolic expressions to the collection of patterns that the query will use to match nodes.
        Parameters:
        patterns - a sequence of symbolic expression strings that make up the pattern
        Returns:
        this builder
        Throws:
        NullPointerException - if the pattern sequence is null
        Since:
        1.8.0
      • pattern

        public Query.Builder pattern​(@NotNull
                                     @NotNull String pattern)
        Adds a symbolic expression to the collection of patterns that the query will use to match nodes.
        Parameters:
        pattern - the symbolic expression string of the query pattern
        Returns:
        this builder
        Throws:
        NullPointerException - if the pattern is null
      • pattern

        public Query.Builder pattern()
        Removes all currently specified query patterns.
        Returns:
        this builder
        Since:
        1.8.0
      • build

        public Query build()
        Builds and returns a new query instance with the configured language and pattern.
        Returns:
        a new query instance
        Throws:
        QueryException - if query construction fails