View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.project.validation;
20  
21  import java.util.ArrayList;
22  import java.util.Collections;
23  import java.util.List;
24  
25  /**
26   */
27  @Deprecated
28  public class ModelValidationResult {
29  
30      /** */
31      private static final String LS = System.lineSeparator();
32  
33      /** */
34      private List<String> messages;
35  
36      public ModelValidationResult() {
37          messages = new ArrayList<>();
38      }
39  
40      public int getMessageCount() {
41          return messages.size();
42      }
43  
44      public String getMessage(int i) {
45          return messages.get(i);
46      }
47  
48      public List<String> getMessages() {
49          return Collections.unmodifiableList(messages);
50      }
51  
52      public void addMessage(String message) {
53          messages.add(message);
54      }
55  
56      public String toString() {
57          return render("");
58      }
59  
60      public String render(String indentation) {
61          if (messages.size() == 0) {
62              return indentation + "There were no validation errors.";
63          }
64  
65          StringBuilder message = new StringBuilder();
66  
67          //        if ( messages.size() == 1 )
68          //        {
69          //            message.append( "There was 1 validation error: " );
70          //        }
71          //        else
72          //        {
73          //            message.append( "There was " + messages.size() + " validation errors: " + LS );
74          //        }
75          //
76          for (int i = 0; i < messages.size(); i++) {
77              message.append(indentation)
78                      .append('[')
79                      .append(i)
80                      .append("]  ")
81                      .append(messages.get(i))
82                      .append(LS);
83          }
84  
85          return message.toString();
86      }
87  }