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.api.services.model;
20  
21  import org.apache.maven.api.services.MavenException;
22  
23  /**
24   * Signals an error when resolving the path to an external model.
25   *
26   */
27  public class ModelResolverException extends MavenException {
28  
29      /**
30       * The group id of the unresolvable model.
31       */
32      private final String groupId;
33  
34      /**
35       * The artifact id of the unresolvable model.
36       */
37      private final String artifactId;
38  
39      /**
40       * The version of the unresolvable model.
41       */
42      private final String version;
43  
44      /**
45       * Creates a new exception with specified detail message and cause.
46       *
47       * @param message The detail message, may be {@code null}.
48       * @param groupId The group id of the unresolvable model, may be {@code null}.
49       * @param artifactId The artifact id of the unresolvable model, may be {@code null}.
50       * @param version The version of the unresolvable model, may be {@code null}.
51       * @param cause The cause, may be {@code null}.
52       */
53      public ModelResolverException(String message, String groupId, String artifactId, String version, Throwable cause) {
54          super(message, cause);
55          this.groupId = (groupId != null) ? groupId : "";
56          this.artifactId = (artifactId != null) ? artifactId : "";
57          this.version = (version != null) ? version : "";
58      }
59  
60      /**
61       * Creates a new exception with specified detail message.
62       *
63       * @param message The detail message, may be {@code null}.
64       * @param groupId The group id of the unresolvable model, may be {@code null}.
65       * @param artifactId The artifact id of the unresolvable model, may be {@code null}.
66       * @param version The version of the unresolvable model, may be {@code null}.
67       */
68      public ModelResolverException(String message, String groupId, String artifactId, String version) {
69          super(message);
70          this.groupId = (groupId != null) ? groupId : "";
71          this.artifactId = (artifactId != null) ? artifactId : "";
72          this.version = (version != null) ? version : "";
73      }
74  
75      /**
76       * Creates a new exception with specified cause
77       *
78       * @param cause
79       * @param groupId
80       * @param artifactId
81       * @param version
82       */
83      public ModelResolverException(Throwable cause, String groupId, String artifactId, String version) {
84          super(cause);
85          this.groupId = groupId;
86          this.artifactId = artifactId;
87          this.version = version;
88      }
89  
90      /**
91       * Gets the group id of the unresolvable model.
92       *
93       * @return The group id of the unresolvable model, can be empty but never {@code null}.
94       */
95      public String getGroupId() {
96          return groupId;
97      }
98  
99      /**
100      * Gets the artifact id of the unresolvable model.
101      *
102      * @return The artifact id of the unresolvable model, can be empty but never {@code null}.
103      */
104     public String getArtifactId() {
105         return artifactId;
106     }
107 
108     /**
109      * Gets the version of the unresolvable model.
110      *
111      * @return The version of the unresolvable model, can be empty but never {@code null}.
112      */
113     public String getVersion() {
114         return version;
115     }
116 }