Sha256: 21b250e4711aa811ab1cb2dcab10cca2cf598347bdca42155292b4829fe9b6e5

Contents?: true

Size: 1016 Bytes

Versions: 1

Compression:

Stored size: 1016 Bytes

Contents

module Neo4j
  module Core
    module Traversal
      # Implements the Neo4j Predicate Java interface, only used internally.
      # @private
      class FilterPredicate
        include Java::OrgNeo4jGraphdbTraversal::PathEvaluator

        def initialize
          @procs = []
        end

        def add(proc)
          @procs << proc
        end

        # for the state parameter see - http://api.neo4j.org/1.8.1/org/neo4j/graphdb/traversal/BranchState.html
        def evaluate(path, state)
          if path.length == 0
            return Java::OrgNeo4jGraphdbTraversal::Evaluation::EXCLUDE_AND_CONTINUE
          end
          # find the first filter which returns false
          # if not found then we will accept this path
          if @procs.find { |p| !p.call(path, state) }.nil?
            Java::OrgNeo4jGraphdbTraversal::Evaluation::INCLUDE_AND_CONTINUE
          else
            Java::OrgNeo4jGraphdbTraversal::Evaluation::EXCLUDE_AND_CONTINUE
          end

        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
neo4j-core-2.2.2-java lib/neo4j-core/traversal/filter_predicate.rb