| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ComparisonOperator |
|
| 14.0;14 |
| 1 | package org.kuali.rice.krms.framework.engine; | |
| 2 | ||
| 3 | 0 | public enum ComparisonOperator { |
| 4 | ||
| 5 | 0 | EQUALS, |
| 6 | 0 | NOT_EQUALS, |
| 7 | 0 | GREATER_THAN, |
| 8 | 0 | GREATER_THAN_EQUAL, |
| 9 | 0 | LESS_THAN, |
| 10 | 0 | LESS_THAN_EQUAL; |
| 11 | ||
| 12 | public <T> boolean compare(Comparable<T> lhs, T rhs) { | |
| 13 | 0 | int result = lhs.compareTo(rhs); |
| 14 | 0 | if (this == EQUALS) { |
| 15 | 0 | return result == 0; |
| 16 | } | |
| 17 | 0 | if (this == NOT_EQUALS) { |
| 18 | 0 | return result != 0; |
| 19 | } | |
| 20 | 0 | if (this == GREATER_THAN) { |
| 21 | 0 | return result > 0; |
| 22 | } | |
| 23 | 0 | if (this == GREATER_THAN_EQUAL) { |
| 24 | 0 | return result >= 0; |
| 25 | } | |
| 26 | 0 | if (this == LESS_THAN) { |
| 27 | 0 | return result < 0; |
| 28 | } | |
| 29 | 0 | if (this == LESS_THAN_EQUAL) { |
| 30 | 0 | return result <= 0; |
| 31 | } | |
| 32 | 0 | throw new IllegalStateException("Invalid operator detected: " + this); |
| 33 | } | |
| 34 | ||
| 35 | ||
| 36 | } |