public static boolean evaluateTrigger(Trigger trigger,Double actualValue){
  requireArgument(trigger != null,"Trigger cannot be null.");
  requireArgument(actualValue != null,"Trigger cannot be evaulated against null.");
  Double lowThreshold, highThreshold;
switch (trigger.type) {
case GREATER_THAN:
    return actualValue.compareTo(trigger.getThreshold()) > 0;
case GREATER_THAN_OR_EQ:
  return actualValue.compareTo(trigger.getThreshold()) >= 0;
case LESS_THAN:
return actualValue.compareTo(trigger.getThreshold()) < 0;
case LESS_THAN_OR_EQ:
return actualValue.compareTo(trigger.getThreshold()) <= 0;
case EQUAL:
return actualValue.compareTo(trigger.getThreshold()) == 0;
case NOT_EQUAL:
return actualValue.compareTo(trigger.getThreshold()) != 0;
case BETWEEN:
lowThreshold=Math.min(trigger.getThreshold(),trigger.getSecondaryThreshold());
highThreshold=Math.max(trigger.getThreshold(),trigger.getSecondaryThreshold());
return (actualValue.compareTo(lowThreshold) >= 0 && actualValue.compareTo(highThreshold) <= 0);
case NOT_BETWEEN:
lowThreshold=Math.min(trigger.getThreshold(),trigger.getSecondaryThreshold());
highThreshold=Math.max(trigger.getThreshold(),trigger.getSecondaryThreshold());
return (actualValue.compareTo(lowThreshold) < 0 || actualValue.compareTo(highThreshold) > 0);
default :
throw new SystemException("Unsupported trigger type " + trigger.type);
}
}

public static boolean evaluateTrigger ( Trigger trigger , Double actualValue ) { requireArgument ( trigger != null , "Trigger cannot be null." ) ; requireArgument ( actualValue != null , "Trigger cannot be evaulated against null." ) ; Double lowThreshold , highThreshold ; switch ( trigger . type ) { case GREATER_THAN : return actualValue . compareTo ( trigger . getThreshold ( ) ) > 0 ; case GREATER_THAN_OR_EQ : return actualValue . compareTo ( trigger . getThreshold ( ) ) >= 0 ; case LESS_THAN : return actualValue . compareTo ( trigger . getThreshold ( ) ) < 0 ; case LESS_THAN_OR_EQ : return actualValue . compareTo ( trigger . getThreshold ( ) ) <= 0 ; case EQUAL : return actualValue . compareTo ( trigger . getThreshold ( ) ) == 0 ; case NOT_EQUAL : return actualValue . compareTo ( trigger . getThreshold ( ) ) != 0 ; case BETWEEN : lowThreshold = Math . min ( trigger . getThreshold ( ) , trigger . getSecondaryThreshold ( ) ) ; highThreshold = Math . max ( trigger . getThreshold ( ) , trigger . getSecondaryThreshold ( ) ) ; return ( actualValue . compareTo ( lowThreshold ) >= 0 && actualValue . compareTo ( highThreshold ) <= 0 ) ; case NOT_BETWEEN : lowThreshold = Math . min ( trigger . getThreshold ( ) , trigger . getSecondaryThreshold ( ) ) ; highThreshold = Math . max ( trigger . getThreshold ( ) , trigger . getSecondaryThreshold ( ) ) ; return ( actualValue . compareTo ( lowThreshold ) < 0 || actualValue . compareTo ( highThreshold ) > 0 ) ; default : throw new SystemException ( "Unsupported trigger type " + trigger . type ) ; } }
evaluates the trigger against actualvalue ( passed as parameter ) .
