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