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  import java.util.Objects;
22  import org.apache.maven.model.InputLocation;
23  import org.apache.maven.model.building.ModelProblem.Severity;
24  import org.apache.maven.model.building.ModelProblem.Version;
25  
26  /**
27   * Class to wrap request parameters to ModelProblemCollector.addProblem
28   *
29   * @author mkleint
30   */
31  public final class ModelProblemCollectorRequest {
32  
33      private final ModelProblem.Severity severity;
34      private final ModelProblem.Version version;
35      private Exception exception;
36      private String message;
37      private InputLocation location;
38  
39      /**
40       * Create a new request with mandatory parameters.
41       * @param severity
42       * @param version
43       */
44      public ModelProblemCollectorRequest(Severity severity, Version version) {
45          this.severity = Objects.requireNonNull(severity, "severity cannot be null");
46          this.version = Objects.requireNonNull(version, "version cannot be null");
47      }
48  
49      public Severity getSeverity() {
50          return severity;
51      }
52  
53      public Version getVersion() {
54          return version;
55      }
56  
57      public Exception getException() {
58          return exception;
59      }
60  
61      public ModelProblemCollectorRequest setException(Exception exception) {
62          this.exception = exception;
63          return this;
64      }
65  
66      public String getMessage() {
67          return message;
68      }
69  
70      public ModelProblemCollectorRequest setMessage(String message) {
71          this.message = message;
72          return this;
73      }
74  
75      public InputLocation getLocation() {
76          return location;
77      }
78  
79      public ModelProblemCollectorRequest setLocation(InputLocation location) {
80          this.location = location;
81          return this;
82      }
83  }