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