001 package org.apache.maven.model.resolution;
002
003 /*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements. See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership. The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License. You may obtain a copy of the License at
011 *
012 * http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied. See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022 /**
023 * Signals an error when resolving the path to an external model.
024 *
025 * @author Benjamin Bentmann
026 */
027 public class UnresolvableModelException
028 extends Exception
029 {
030
031 /**
032 * The group id of the unresolvable model.
033 */
034 private final String groupId;
035
036 /**
037 * The artifact id of the unresolvable model.
038 */
039 private final String artifactId;
040
041 /**
042 * The version of the unresolvable model.
043 */
044 private final String version;
045
046 /**
047 * Creates a new exception with specified detail message and cause.
048 *
049 * @param message The detail message, may be {@code null}.
050 * @param groupId The group id of the unresolvable model, may be {@code null}.
051 * @param artifactId The artifact id of the unresolvable model, may be {@code null}.
052 * @param version The version of the unresolvable model, may be {@code null}.
053 * @param cause The cause, may be {@code null}.
054 */
055 public UnresolvableModelException( String message, String groupId, String artifactId, String version,
056 Throwable cause )
057 {
058 super( message, cause );
059 this.groupId = ( groupId != null ) ? groupId : "";
060 this.artifactId = ( artifactId != null ) ? artifactId : "";
061 this.version = ( version != null ) ? version : "";
062 }
063
064 /**
065 * Creates a new exception with specified detail message.
066 *
067 * @param message The detail message, may be {@code null}.
068 * @param groupId The group id of the unresolvable model, may be {@code null}.
069 * @param artifactId The artifact id of the unresolvable model, may be {@code null}.
070 * @param version The version of the unresolvable model, may be {@code null}.
071 */
072 public UnresolvableModelException( String message, String groupId, String artifactId, String version )
073 {
074 super( message );
075 this.groupId = ( groupId != null ) ? groupId : "";
076 this.artifactId = ( artifactId != null ) ? artifactId : "";
077 this.version = ( version != null ) ? version : "";
078 }
079
080 /**
081 * Gets the group id of the unresolvable model.
082 *
083 * @return The group id of the unresolvable model, can be empty but never {@code null}.
084 */
085 public String getGroupId()
086 {
087 return groupId;
088 }
089
090 /**
091 * Gets the artifact id of the unresolvable model.
092 *
093 * @return The artifact id of the unresolvable model, can be empty but never {@code null}.
094 */
095 public String getArtifactId()
096 {
097 return artifactId;
098 }
099
100 /**
101 * Gets the version of the unresolvable model.
102 *
103 * @return The version of the unresolvable model, can be empty but never {@code null}.
104 */
105 public String getVersion()
106 {
107 return version;
108 }
109
110 }