class ConditionEvaluator {

    public boolean evaluate(final Condition condition, final WilmaHttpRequest request) {
        boolean fulfilled = false;
        if (condition instanceof CompositeCondition) {
            if (condition.getConditionType() == ConditionType.AND) {
                fulfilled = evaluateAndCondition(condition, request);
            } else if (condition.getConditionType() == ConditionType.OR) {
                fulfilled = evaluateOrCondition(condition, request);
            } else if (condition.getConditionType() == ConditionType.NOT) {
                fulfilled = evaluateNotCondition(condition, request);
            }
        } else if (condition instanceof SimpleCondition) {
            SimpleCondition simpleCondition = (SimpleCondition) condition;
            ConditionChecker conditionChecker = simpleCondition.getConditionChecker();
            boolean negate = simpleCondition.isNegate();
            fulfilled = !negate && conditionChecker.checkCondition(request, simpleCondition.getParameters());
        }
        return fulfilled;
    }

}