1
|
package eu.etaxonomy.cdm.validation.constraint;
|
2
|
|
3
|
import javax.validation.ConstraintValidator;
|
4
|
import javax.validation.ConstraintValidatorContext;
|
5
|
|
6
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
7
|
import eu.etaxonomy.cdm.validation.annotation.NoRecursiveInReference;
|
8
|
|
9
|
public class NoRecursiveInReferenceValidator implements ConstraintValidator<NoRecursiveInReference, Reference> {
|
10
|
|
11
|
@Override
|
12
|
public void initialize(NoRecursiveInReference constraintAnnotation) {}
|
13
|
|
14
|
@Override
|
15
|
public boolean isValid(Reference value, ConstraintValidatorContext constraintValidatorContext) {
|
16
|
boolean isValid = true;
|
17
|
try {
|
18
|
if (value.getInReference() != null && value.equals(value.getInReference())){
|
19
|
isValid = false;
|
20
|
}
|
21
|
}catch(NullPointerException e){
|
22
|
return isValid;
|
23
|
}
|
24
|
|
25
|
return isValid;
|
26
|
}
|
27
|
|
28
|
}
|