Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ValidationResult |
|
| 2.0;2 |
1 | package org.apache.maven.doxia.book.services.validation; | |
2 | ||
3 | /* | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
20 | */ | |
21 | ||
22 | import java.util.List; | |
23 | import java.util.ArrayList; | |
24 | ||
25 | /** | |
26 | * Encapsulates the result of a validation. | |
27 | * | |
28 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> | |
29 | * @version $Id: ValidationResult.java 1090706 2011-04-09 23:15:28Z hboutemy $ | |
30 | */ | |
31 | 12 | public class ValidationResult |
32 | { | |
33 | /** List of errors. */ | |
34 | private List<String> errors; | |
35 | ||
36 | /** List of warnings. */ | |
37 | private List<String> warnings; | |
38 | ||
39 | /** | |
40 | * Checks if there were any errors or warnings. | |
41 | * | |
42 | * @return True if there were no errors or warnings. | |
43 | */ | |
44 | public boolean isAllOk() | |
45 | { | |
46 | 12 | return getErrors().size() == 0 && getWarnings().size() == 0; |
47 | } | |
48 | ||
49 | /** | |
50 | * Return the list of errors. | |
51 | * | |
52 | * @return List. A new ArrayList is constructed if the current List is null. | |
53 | */ | |
54 | public List<String> getErrors() | |
55 | { | |
56 | 12 | if ( errors == null ) |
57 | { | |
58 | 12 | errors = new ArrayList<String>(); |
59 | } | |
60 | ||
61 | 12 | return errors; |
62 | } | |
63 | ||
64 | /** | |
65 | * Return the list of warnings. | |
66 | * | |
67 | * @return List. A new ArrayList is constructed if the current List is null. | |
68 | */ | |
69 | public List<String> getWarnings() | |
70 | { | |
71 | 12 | if ( warnings == null ) |
72 | { | |
73 | 12 | warnings = new ArrayList<String>(); |
74 | } | |
75 | ||
76 | 12 | return warnings; |
77 | } | |
78 | } |