1 package org.apache.maven.project.validation;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.ArrayList;
23 import java.util.Collections;
24 import java.util.List;
25
26
27
28
29 public class ModelValidationResult
30 {
31
32
33 private static final String NEWLINE = System.getProperty( "line.separator" );
34
35
36 private List<String> messages;
37
38 public ModelValidationResult()
39 {
40 messages = new ArrayList<String>();
41 }
42
43 public int getMessageCount()
44 {
45 return messages.size();
46 }
47
48 public String getMessage( int i )
49 {
50 return messages.get( i );
51 }
52
53 public List<String> getMessages()
54 {
55 return Collections.unmodifiableList( messages );
56 }
57
58 public void addMessage( String message )
59 {
60 messages.add( message );
61 }
62
63 public String toString()
64 {
65 return render( "" );
66 }
67
68 public String render( String indentation )
69 {
70 if ( messages.size() == 0 )
71 {
72 return indentation + "There were no validation errors.";
73 }
74
75 StringBuilder message = new StringBuilder();
76
77
78
79
80
81
82
83
84
85
86 for ( int i = 0; i < messages.size(); i++ )
87 {
88 message.append( indentation + "[" + i + "] " + messages.get( i ) + NEWLINE );
89 }
90
91 return message.toString();
92 }
93
94 }