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