class CheckAggregateDefinitionValidator implements ConstraintValidator<CheckAggregateDefinition, ClientQueryAggregatedField>,
        ValidationErrorDescriptorBuilder {

    @Override
    public boolean isValid(ClientQueryAggregatedField value, ConstraintValidatorContext context) {
        boolean isDefault = (value.getAggregateFunction() == null && value.getAggregateExpression() == null);
        boolean isBuiltin = (value.getAggregateFunction() != null && !value.getAggregateFunction().isEmpty());
        boolean isCustom = (value.getAggregateExpression() != null && !value.getAggregateExpression().isEmpty())
                || (value.getExpressionContainer() != null);


        return isDefault || (isBuiltin && !isCustom) || (isCustom && !isBuiltin);
    }

}