package gw.rating.rtm.matchop uses gw.api.database.Query uses gw.api.database.Relop uses gw.rating.rtm.domain.OrderedPersistenceAdapter uses java.lang.Comparable uses java.math.RoundingMode @ReadOnly class StatelessLessThanMatch extends StatelessLessThanOrEqualMatch { construct(matchOp : RateTableMatchOp) { super(matchOp) } override function filter(query: Query, arg: Comparable) { // DB layer forces us to compare Column to arg rather than the inverse. // So this matchop actually computes Column > arg, not arg < Column query.compare(ColumnName, Relop.GreaterThan, arg) } override protected function compareMin(bean : OrderedPersistenceAdapter, arg : Comparable) : int { // Return "equal" until we encounter a bean which is <= arg return bean.get(this.ArgIndex).compareTo(arg) > 0 ? 0 : -1 } override protected function getRounding(paramIndex : int) : RoundingMode { // input value 2.5 vs row value 3 should match (2.5 < 3); vs row value 2 (2.5 < 2) should not // we actually compute the reverse, i.e. (3 > 2.5) and (2 > 2.5) // so we convert input value 2.5 to 2, giving (3 > 2) and (2 > 2) return FLOOR } }