23 lines
567 B
Java
23 lines
567 B
Java
package org.baeldung.event;
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
import org.springframework.data.annotation.Id;
|
|
import org.springframework.util.ReflectionUtils;
|
|
|
|
public class DbRefFieldCallback implements ReflectionUtils.FieldCallback {
|
|
private boolean idFound;
|
|
|
|
public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException {
|
|
ReflectionUtils.makeAccessible(field);
|
|
|
|
if (field.isAnnotationPresent(Id.class)) {
|
|
idFound = true;
|
|
}
|
|
}
|
|
|
|
public boolean isIdFound() {
|
|
return idFound;
|
|
}
|
|
}
|