* @return true if the validation was applied.
*/
public boolean apply(final Mapper mapper, final Class<?> type, final Object value, final List<ValidationFailure> validationFailures) {
if (appliesTo(mapper, type)) {
Class<?> classOfValue = value.getClass();
MappedClass mappedClassForType = mapper.getMappedClass(type);
Class classOfIdFieldForType = mappedClassForType.getMappedIdField().getConcreteType();
if (!type.equals(value.getClass()) && !classOfValue.equals(classOfIdFieldForType)) {
validationFailures.add(new ValidationFailure(format("The value class needs to match the type of ID for the field. "
+ "Value was %s and was a %s and the ID of the type was %s",
value, classOfValue, classOfIdFieldForType
)));