class ConsistentReferenceNameValidator implements ConstraintValidator<ConsistentReferenceName, ReferenceElement>,
        ValidationErrorDescriptorBuilder {

    @Override
    public boolean isValid(ReferenceElement value, ConstraintValidatorContext context) {
        boolean result = true;
        final String referencePath = value.getReferencePath();
        if(referencePath != null && value.getName() != null){
            result = value.getName().equals(getReferencedResourceName(referencePath));
        }
        return result;
    }

}