Project

General

Profile

Download (1.17 KB) 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
package eu.etaxonomy.cdm.persistence.validation;
10

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

    
14
/**
15
 * A Mock class for testing entity validation tasks. DO NOT MODIFY UNLESS YOU
16
 * ALSO MODIFY THE UNIT TESTS MAKING USE OF THIS CLASS!
17
 *
18
 * @author ayco_holleman
19
 *
20
 */
21
public class CheckCaseValidator implements ConstraintValidator<CheckCase, String> {
22
	private CaseMode caseMode;
23

    
24

    
25
	@Override
26
    public void initialize(CheckCase constraintAnnotation){
27
		this.caseMode = constraintAnnotation.value();
28
	}
29

    
30

    
31
	@Override
32
    public boolean isValid(String object, ConstraintValidatorContext constraintContext){
33
		if (object == null) {
34
            return true;
35
        }
36
		if (caseMode == CaseMode.UPPER) {
37
            return object.equals(object.toUpperCase());
38
        } else {
39
            return object.equals(object.toLowerCase());
40
        }
41
	}
42
}
(4-4/12)