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