Sha256: 963070148b8933cad15f8f45865d22640e560771158ea2ce549796317a12e759

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

module Pacer::Pipes
  class PropertyComparisonFilterPipe < RubyPipe
    def initialize(left, right, filter)
      super()
      @filter = filter
      @left = left.to_s
      @right = right.to_s
    end

    protected

    def processNextStart
      while true
        obj = @starts.next
        l = obj.getProperty(@left)
        r = obj.getProperty(@right)
        case @filter
        when FilterPipe::Filter::EQUAL
          return obj if l == r
        when FilterPipe::Filter::NOT_EQUAL
          return obj if l != r
        when FilterPipe::Filter::GREATER_THAN
          return obj if l and r and l > r
        when FilterPipe::Filter::LESS_THAN
          return obj if l and r and l < r
        when FilterPipe::Filter::GREATER_THAN_EQUAL
          return obj if l and r and l >= r
        when FilterPipe::Filter::LESS_THAN_EQUAL
          return obj if l and r and l <= r
        end
      end
    rescue NativeException => e
      if e.cause.getClass == Pacer::NoSuchElementException.getClass
        raise e.cause
      else
        raise e
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pacer-0.9.1.1-java lib/pacer/pipe/property_comparison_pipe.rb