View Javadoc
1   package org.apache.maven.model.building;
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  /**
23   * Describes a problem that was encountered during model building. A problem can either be an exception that was thrown
24   * or a simple string message. In addition, a problem carries a hint about its source, e.g. the POM file that exhibits
25   * the problem.
26   *
27   * @author Benjamin Bentmann
28   */
29  public interface ModelProblem
30  {
31  
32      /**
33       * The different severity levels for a problem, in decreasing order.
34       */
35      enum Severity
36      {
37  
38          FATAL, //
39          ERROR, //
40          WARNING //
41  
42      }
43  
44      /**
45       * Version
46       */
47      enum Version
48      {
49          //based on ModeBuildingResult.validationLevel
50          BASE,
51          V20,
52          V30,
53          V31
54      }
55  
56      /**
57       * Gets the hint about the source of the problem. While the syntax of this hint is unspecified and depends on the
58       * creator of the problem, the general expectation is that the hint provides sufficient information to the user to
59       * track the problem back to its origin. A concrete example for such a source hint can be the file path or URL from
60       * which a POM was read.
61       *
62       * @return The hint about the source of the problem or an empty string if unknown, never {@code null}.
63       */
64      String getSource();
65  
66      /**
67       * Gets the one-based index of the line containing the problem. The line number should refer to some text file that
68       * is given by {@link #getSource()}.
69       *
70       * @return The one-based index of the line containing the problem or a non-positive value if unknown.
71       */
72      int getLineNumber();
73  
74      /**
75       * Gets the one-based index of the column containing the problem. The column number should refer to some text file
76       * that is given by {@link #getSource()}.
77       *
78       * @return The one-based index of the column containing the problem or non-positive value if unknown.
79       */
80      int getColumnNumber();
81  
82      /**
83       * Gets the identifier of the model from which the problem originated. While the general form of this identifier is
84       * <code>groupId:artifactId:version</code> the returned identifier need not be complete. The identifier is derived
85       * from the information that is available at the point the problem occurs and as such merely serves as a best effort
86       * to provide information to the user to track the problem back to its origin.
87       *
88       * @return The identifier of the model from which the problem originated or an empty string if unknown, never
89       *         {@code null}.
90       */
91      String getModelId();
92  
93      /**
94       * Gets the exception that caused this problem (if any).
95       *
96       * @return The exception that caused this problem or {@code null} if not applicable.
97       */
98      Exception getException();
99  
100     /**
101      * Gets the message that describes this problem.
102      *
103      * @return The message describing this problem, never {@code null}.
104      */
105     String getMessage();
106 
107     /**
108      * Gets the severity level of this problem.
109      *
110      * @return The severity level of this problem, never {@code null}.
111      */
112     Severity getSeverity();
113 
114     /**
115      * Gets the applicable maven version/validation level of this problem
116      * @return The version, never {@code null}.
117      */
118     Version getVersion();
119 
120 }