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
30 public class ModelValidationResult
31 {
32
33
34 private static final String NEWLINE = System.getProperty( "line.separator" );
35
36
37 private List<String> messages;
38
39 public ModelValidationResult()
40 {
41 messages = new ArrayList<String>();
42 }
43
44 public int getMessageCount()
45 {
46 return messages.size();
47 }
48
49 public String getMessage( int i )
50 {
51 return messages.get( i );
52 }
53
54 public List<String> getMessages()
55 {
56 return Collections.unmodifiableList( messages );
57 }
58
59 public void addMessage( String message )
60 {
61 messages.add( message );
62 }
63
64 public String toString()
65 {
66 return render( "" );
67 }
68
69 public String render( String indentation )
70 {
71 if ( messages.size() == 0 )
72 {
73 return indentation + "There were no validation errors.";
74 }
75
76 StringBuilder message = new StringBuilder();
77
78
79
80
81
82
83
84
85
86
87 for ( int i = 0; i < messages.size(); i++ )
88 {
89 message.append( indentation + "[" + i + "] " + messages.get( i ).toString() + NEWLINE );
90 }
91
92 return message.toString();
93 }
94
95 }