class GenericOrderFieldReferenceValidator implements ConstraintValidator<CheckGenericOrderFieldReference, ClientGenericOrder>, ValidationErrorDescriptorBuilder {

    @Override
    public boolean isValid(ClientGenericOrder order, ConstraintValidatorContext context) {
        if (EMPTY.equals(order.getFieldReference())) return false;

        return order.getFieldReference() != null ^ order.isAggregationLevel();
    }

}