Project

General

Profile

Download (845 Bytes) Statistics
| Branch: | Tag: | Revision:
1 e902c13e Andreas Müller
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 90046bc4 Andreas Müller
public class NoRecursiveInReferenceValidator implements ConstraintValidator<NoRecursiveInReference, Reference> {
10 e902c13e Andreas Müller
11
	@Override
12
    public void initialize(NoRecursiveInReference constraintAnnotation) {}
13
14
	@Override
15 90046bc4 Andreas Müller
    public boolean isValid(Reference value, ConstraintValidatorContext constraintValidatorContext) {
16 e902c13e Andreas Müller
		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
}