Project

General

Profile

Download (908 Bytes) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/ 
9

    
10
package eu.etaxonomy.cdm.validation.constraint;
11

    
12
import javax.validation.ConstraintValidator;
13
import javax.validation.ConstraintValidatorContext;
14

    
15
import eu.etaxonomy.cdm.validation.annotation.NullOrNotEmpty;
16

    
17
public class NullOrNotEmptyValidator implements ConstraintValidator<NullOrNotEmpty, String> {
18

    
19
	public void initialize(NullOrNotEmpty nullOrNotEmpty) { }
20

    
21
	public boolean isValid(String string, ConstraintValidatorContext constraintContext) {
22
		boolean isValid = false;
23
		if(string == null) {
24
			isValid = true;
25
		} else if(string.trim().length() > 0) {
26
			isValid =  true;
27
		}
28
		
29
		return isValid;
30
	}
31
}
(10-10/13)