1 /********************************************** 2 * Copyright (C) 2011 Lukas Laag 3 * This file is part of svgreal. 4 * 5 * svgreal is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * svgreal is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with svgreal. If not, see http://www.gnu.org/licenses/ 17 **********************************************/ 18 package org.vectomatic.svg.edit.client.model; 19 20 import java.util.Set; 21 22 import org.vectomatic.svg.edit.client.model.ValidationError.Severity; 23 24 /** 25 * Interface for models which support validation 26 * @author laaglu 27 */ 28 public interface IValidatable<T> { 29 /** 30 * Returns the severity for this model. Null 31 * values mean that the model is valid. 32 * {@link org.vectomatic.svg.edit.client.model.ValidationError.Severity#WARNING} 33 * means that the model has at least one warning, but no errors. 34 * {@link org.vectomatic.svg.edit.client.model.ValidationError.Severity#ERROR} 35 * means that the model has at least one error. 36 * @return 37 */ 38 public Severity getSeverity(); 39 /** 40 * Updates the severity for this model. The severity for 41 * the parent model of this model is updated, recursively. 42 * If the supplied severity is less severe than the 43 * present severity, the actual severity for this model 44 * will be computed by taking the most severe severity 45 * of all the child model or metadata of this model. 46 * @param severity the severity 47 */ 48 public void updateSeverity(Severity severity); 49 /** 50 * Returns the errors of the specified severity 51 * associated with this model. 52 * @param severity The severity. If null, both errors 53 * and warnings are returned 54 * @return the errors associated with this model. 55 */ 56 public Set<ValidationError> getErrors(T model, Severity severity); 57 58 }