2 * Copyright (C) 2019 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.cdm
.vaadin
.data
.validator
;
11 import org
.joda
.time
.DateTimeFieldType
;
12 import org
.joda
.time
.Partial
;
14 import com
.vaadin
.data
.Validator
;
17 * @author a.kohlbecker
21 public class PartialCompletenesValidator
implements Validator
{
23 private static final long serialVersionUID
= -2739242148516872452L;
26 public void validate(Object value
) throws InvalidValueException
{
28 Partial partial
= (Partial
)value
;
30 if(partial
.isSupported(DateTimeFieldType
.monthOfYear())
31 && !partial
.isSupported(DateTimeFieldType
.year())
33 throw new InvalidValueException("The Partial must support year if monthOfYear is set");
35 if(partial
.isSupported(DateTimeFieldType
.dayOfMonth())
37 partial
.isSupported(DateTimeFieldType
.monthOfYear())
38 && partial
.isSupported(DateTimeFieldType
.year())
41 throw new InvalidValueException("The Partial must support monthOfYear and year if dayOfMonth is set");