View Javadoc

1   /*
2    * Copyright 2006-2016 The JGUIraffe Team.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License")
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package net.sf.jguiraffe.transform;
17  
18  import java.util.Collection;
19  
20  /**
21   * <p>
22   * An interface that defines the results of a validation process.
23   * </p>
24   * <p>
25   * Instances of this class are returned by {@link Validator} objects. They
26   * contain all information about the validation results: a flag whether the
27   * validation was successful and a list with messages generating during the
28   * validation operation. Messages can be either error or warning messages.
29   * </p>
30   *
31   * @author Oliver Heger
32   * @version $Id: ValidationResult.java 205 2012-01-29 18:29:57Z oheger $
33   */
34  public interface ValidationResult
35  {
36      /**
37       * Returns a flag if the validation was successful. If this method returns
38       * <b>true</b>, the checked object can be considered valid.
39       *
40       * @return a flag if the validation was successful
41       */
42      boolean isValid();
43  
44      /**
45       * Returns a collection with all {@code ValidationMessage} objects that were
46       * created during validation. If {@link #isValid()} returns <b>false</b>,
47       * this collection should at least contain one element with the
48       * {@link ValidationMessageLevel} {@code ERROR}. The objects in the returned
49       * collection can be used to find out, which specific errors have been
50       * occurred and for displaying messages to the user. The returned list must
51       * not be <b>null</b>.
52       *
53       * @return a list with validation messages
54       */
55      Collection<ValidationMessage> getValidationMessages();
56  
57      /**
58       * Returns a flag whether this object contains validation messages of the
59       * specified level. This is convenient to find out whether there are errors
60       * or warnings without having to actually retrieve the messages.
61       *
62       * @param level the {@code ValidationMessageLevel} to check
63       * @return a flag whether there are messages of this {@code
64       *         ValidationMessageLevel}
65       */
66      boolean hasMessages(ValidationMessageLevel level);
67  
68      /**
69       * Returns a collection with all {@code ValidationMessage} objects of the
70       * specified level that were created during validation. This method allows
71       * filtering for a specific message level. An implementation should never
72       * return <b>null</b>.
73       *
74       * @param level the {@code ValidationMessageLevel}
75       * @return a collection with the available messages of this level
76       */
77      Collection<ValidationMessage> getValidationMessages(
78              ValidationMessageLevel level);
79  }