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 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  
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      {
47          this.severity = severity;
48          this.version = version;
49          if ( severity == null )
50          {
51              throw new IllegalStateException( "No severity declared" );
52          }
53          if ( version == null )
54          {
55              throw new IllegalStateException( "No version declared." );
56          }
57      }
58  
59      public Severity getSeverity()
60      {
61          return severity;
62      }
63  
64      public Version getVersion()
65      {
66          return version;
67      }
68  
69      public Exception getException()
70      {
71          return exception;
72      }
73  
74      public ModelProblemCollectorRequest setException( Exception exception )
75      {
76          this.exception = exception;
77          return this;
78      }
79  
80      public String getMessage()
81      {
82          return message;
83      }
84  
85      public ModelProblemCollectorRequest setMessage( String message )
86      {
87          this.message = message;
88          return this;
89      }
90  
91      public InputLocation getLocation()
92      {
93          return location;
94      }
95  
96      public ModelProblemCollectorRequest setLocation( InputLocation location )
97      {
98          this.location = location;
99          return this;
100     }
101 }