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; 20 21 /** 22 * Signals an error when resolving the path to an external model. 23 * 24 */ 25 public class ModelResolverException extends MavenException { 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 ModelResolverException(String message, String groupId, String artifactId, String version, Throwable cause) { 52 super(message, cause); 53 this.groupId = (groupId != null) ? groupId : ""; 54 this.artifactId = (artifactId != null) ? artifactId : ""; 55 this.version = (version != null) ? version : ""; 56 } 57 58 /** 59 * Creates a new exception with specified detail message. 60 * 61 * @param message The detail message, may be {@code null}. 62 * @param groupId The group id of the unresolvable model, may be {@code null}. 63 * @param artifactId The artifact id of the unresolvable model, may be {@code null}. 64 * @param version The version of the unresolvable model, may be {@code null}. 65 */ 66 public ModelResolverException(String message, String groupId, String artifactId, String version) { 67 super(message); 68 this.groupId = (groupId != null) ? groupId : ""; 69 this.artifactId = (artifactId != null) ? artifactId : ""; 70 this.version = (version != null) ? version : ""; 71 } 72 73 /** 74 * Creates a new exception with specified cause 75 * 76 * @param cause 77 * @param groupId 78 * @param artifactId 79 * @param version 80 */ 81 public ModelResolverException(Throwable cause, String groupId, String artifactId, String version) { 82 super(cause); 83 this.groupId = groupId; 84 this.artifactId = artifactId; 85 this.version = version; 86 } 87 88 /** 89 * Gets the group id of the unresolvable model. 90 * 91 * @return The group id of the unresolvable model, can be empty but never {@code null}. 92 */ 93 public String getGroupId() { 94 return groupId; 95 } 96 97 /** 98 * Gets the artifact id of the unresolvable model. 99 * 100 * @return The artifact id of the unresolvable model, can be empty but never {@code null}. 101 */ 102 public String getArtifactId() { 103 return artifactId; 104 } 105 106 /** 107 * Gets the version of the unresolvable model. 108 * 109 * @return The version of the unresolvable model, can be empty but never {@code null}. 110 */ 111 public String getVersion() { 112 return version; 113 } 114 }