class MonetaryAmountAcceptedValidator implements ConstraintValidator<CurrencyAccepted, MonetaryAmount> {

    @Override
    public boolean isValid(MonetaryAmount value,
                           ConstraintValidatorContext context) {
        if (value == null) {
            return true;
        }
        return containsCurrency(value.getCurrency());
    }

}