View Javadoc

1   /*
2    * Copyright 2012 The Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.maven.model.building;
17  
18  import org.apache.maven.model.InputLocation;
19  import org.apache.maven.model.building.ModelProblem.Severity;
20  import org.apache.maven.model.building.ModelProblem.Version;
21  
22  /**
23   * Class to wrap request parameters to ModelProblemCollector.addProblem
24   *
25   * @author mkleint
26   */
27  public final class ModelProblemCollectorRequest
28  {
29  
30      private final ModelProblem.Severity severity;
31      private final ModelProblem.Version version;
32      private Exception exception;
33      private String message;
34      private InputLocation location;
35      
36      /**
37       * Create a new request with mandatory parameters.
38       * @param severity
39       * @param version 
40       */
41      public ModelProblemCollectorRequest(Severity severity, Version version)
42      {
43          this.severity = severity;
44          this.version = version;
45          if (severity == null)
46          {
47              throw new IllegalStateException("No severity declared");
48          }
49          if (version == null)
50          {
51              throw new IllegalStateException("No version declared.");
52          }
53      }
54  
55      public Severity getSeverity()
56      {
57          return severity;
58      }
59  
60      public Version getVersion()
61      {
62          return version;
63      }
64  
65      public Exception getException()
66      {
67          return exception;
68      }
69  
70      public ModelProblemCollectorRequest setException(Exception exception)
71      {
72          this.exception = exception;
73          return this;
74      }
75  
76      public String getMessage()
77      {
78          return message;
79      }
80  
81      public ModelProblemCollectorRequest setMessage(String message)
82      {
83          this.message = message;
84          return this;
85      }
86  
87      public InputLocation getLocation()
88      {
89          return location;
90      }
91  
92      public ModelProblemCollectorRequest setLocation(InputLocation location)
93      {
94          this.location = location;
95          return this;
96      }
97  }