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.resolution;
20  
21  /**
22   * Signals an error when resolving the path to an external model.
23   *
24   * @author Benjamin Bentmann
25   */
26  public class UnresolvableModelException extends Exception {
27  
28      /**
29       * The group id of the unresolvable model.
30       */
31      private final String groupId;
32  
33      /**
34       * The artifact id of the unresolvable model.
35       */
36      private final String artifactId;
37  
38      /**
39       * The version of the unresolvable model.
40       */
41      private final String version;
42  
43      /**
44       * Creates a new exception with specified detail message and cause.
45       *
46       * @param message The detail message, may be {@code null}.
47       * @param groupId The group id of the unresolvable model, may be {@code null}.
48       * @param artifactId The artifact id of the unresolvable model, may be {@code null}.
49       * @param version The version of the unresolvable model, may be {@code null}.
50       * @param cause The cause, may be {@code null}.
51       */
52      public UnresolvableModelException(
53              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 UnresolvableModelException(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 UnresolvableModelException(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 }