Project

General

Profile

Download (938 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
    @Override
20
    public void initialize(NullOrNotEmpty nullOrNotEmpty) { }
21

    
22
    @Override
23
	public boolean isValid(String string, ConstraintValidatorContext constraintContext) {
24
		boolean isValid = false;
25
		if(string == null) {
26
			isValid = true;
27
		} else if(string.trim().length() > 0) {
28
			isValid =  true;
29
		}
30

    
31
		return isValid;
32
	}
33
}
(12-12/17)