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