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.api.services; 20 21 import org.apache.maven.api.annotations.Experimental; 22 import org.apache.maven.api.annotations.Immutable; 23 import org.apache.maven.api.annotations.Nonnull; 24 import org.apache.maven.api.annotations.Nullable; 25 26 /** 27 * Describes a problem that was encountered during project building. A problem can either be an exception that was 28 * thrown or a simple string message. In addition, a problem carries a hint about its source. 29 * 30 * @since 4.0.0 31 */ 32 @Experimental 33 @Immutable 34 public interface BuilderProblem { 35 36 /** 37 * Gets the hint about the source of the problem. While the syntax of this hint is unspecified and depends on the 38 * creator of the problem, the general expectation is that the hint provides sufficient information to the user to 39 * track the problem back to its origin. A concrete example for such a source hint can be the file path or URL from 40 * which the settings were read. 41 * 42 * @return the hint about the source of the problem or an empty string if unknown, never {@code null} 43 */ 44 @Nonnull 45 String getSource(); 46 47 /** 48 * Gets the one-based index of the line containing the problem. The line number should refer to some text file that 49 * is given by {@link #getSource()}. 50 * 51 * @return the one-based index of the line containing the problem or a non-positive value if unknown 52 */ 53 int getLineNumber(); 54 55 /** 56 * Gets the one-based index of the column containing the problem. The column number should refer to some text file 57 * that is given by {@link #getSource()}. 58 * 59 * @return the one-based index of the column containing the problem or non-positive value if unknown 60 */ 61 int getColumnNumber(); 62 63 /** 64 * Gets the location of the problem. The location is a user-friendly combination of the values from 65 * {@link #getSource()}, {@link #getLineNumber()} and {@link #getColumnNumber()}. The exact syntax of the returned 66 * value is undefined. 67 * 68 * @return the location of the problem, never {@code null} 69 */ 70 @Nonnull 71 String getLocation(); 72 73 /** 74 * Gets the exception that caused this problem (if any). 75 * 76 * @return the exception that caused this problem or {@code null} if not applicable 77 */ 78 @Nullable 79 Exception getException(); 80 81 /** 82 * Gets the message that describes this problem. 83 * 84 * @return the message describing this problem, never {@code null} 85 */ 86 @Nonnull 87 String getMessage(); 88 89 /** 90 * Gets the severity level of this problem. 91 * 92 * @return the severity level of this problem, never {@code null} 93 */ 94 @Nonnull 95 Severity getSeverity(); 96 97 /** 98 * The different severity levels for a problem, in decreasing order. 99 * 100 * @since 4.0.0 101 */ 102 @Experimental 103 enum Severity { 104 FATAL, // 105 ERROR, // 106 WARNING // 107 } 108 }