1 /* 2 * Copyright 2012-2013 smartics, Kronseder & Reiner GmbH 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package de.smartics.maven.nexus; 17 18 import de.smartics.util.lang.Arg; 19 20 /** 21 * The data to send to the Nexus server to access artifact resolution 22 * information. 23 */ 24 public final class NexusRequest 25 { 26 // ********************************* Fields ********************************* 27 28 // --- constants ------------------------------------------------------------ 29 30 // --- members -------------------------------------------------------------- 31 32 /** 33 * The path to the Nexus server. 34 */ 35 private final String nexusServer; 36 37 /** 38 * The identifier of the repository to query on the given nexus server. 39 */ 40 private final String repositoryId; 41 42 /** 43 * The group identifier of the requested artifact. 44 */ 45 private final String groupId; 46 47 /** 48 * The identifier of the requested artifact. 49 */ 50 private final String artifactId; 51 52 /** 53 * The extension of the file of the requested artifact. 54 */ 55 private final String extension; 56 57 // ****************************** Initializer ******************************* 58 59 // ****************************** Constructors ****************************** 60 61 /** 62 * Default constructor. 63 * 64 * @param nexusServer the path to the Nexus server. 65 * @param repositoryId the identifier of the repository to query on the given 66 * nexus server. 67 * @param groupId the group identifier of the requested artifact. 68 * @param artifactId the identifier of the requested artifact. 69 * @param extension the extension of the file of the requested artifact. 70 * @throws NullPointerException if any parameter value is <code>null</code>. 71 * @throws IllegalArgumentException if any parameter value is blank. 72 */ 73 public NexusRequest(final String nexusServer, final String repositoryId, 74 final String groupId, final String artifactId, final String extension) 75 throws NullPointerException, IllegalArgumentException 76 { 77 this.nexusServer = Arg.checkNotBlank("nexusServer", nexusServer); 78 this.repositoryId = Arg.checkNotBlank("repositoryId", repositoryId); 79 this.groupId = Arg.checkNotBlank("groupId", groupId); 80 this.artifactId = Arg.checkNotBlank("artifactId", artifactId); 81 this.extension = Arg.checkNotBlank("extension", extension); 82 } 83 84 // ****************************** Inner Classes ***************************** 85 86 // ********************************* Methods ******************************** 87 88 // --- init ----------------------------------------------------------------- 89 90 // --- get&set -------------------------------------------------------------- 91 92 /** 93 * Returns the path to the Nexus server. 94 * 95 * @return the path to the Nexus server. 96 */ 97 public String getNexusServer() 98 { 99 return nexusServer; 100 } 101 102 /** 103 * Returns the identifier of the repository to query on the given nexus 104 * server. 105 * 106 * @return the identifier of the repository to query on the given nexus 107 * server. 108 */ 109 public String getRepositoryId() 110 { 111 return repositoryId; 112 } 113 114 /** 115 * Returns the group identifier of the requested artifact. 116 * 117 * @return the group identifier of the requested artifact. 118 */ 119 public String getGroupId() 120 { 121 return groupId; 122 } 123 124 /** 125 * Returns the identifier of the requested artifact. 126 * 127 * @return the identifier of the requested artifact. 128 */ 129 public String getArtifactId() 130 { 131 return artifactId; 132 } 133 134 /** 135 * Returns the string representation of the artifact. 136 * 137 * @return the string representation of the artifact. 138 */ 139 public String getArtifactString() 140 { 141 return groupId + ':' + artifactId; 142 } 143 144 /** 145 * Returns the extension of the file of the requested artifact. 146 * 147 * @return the extension of the file of the requested artifact. 148 */ 149 public String getExtension() 150 { 151 return extension; 152 } 153 154 // --- business ------------------------------------------------------------- 155 156 // --- object basics -------------------------------------------------------- 157 158 /** 159 * Returns the string representation of the object. 160 * 161 * @return the string representation of the object. 162 */ 163 @Override 164 public String toString() 165 { 166 final StringBuilder buffer = new StringBuilder(); 167 168 buffer.append(nexusServer).append(':').append(repositoryId).append(':') 169 .append(groupId).append(':').append(artifactId).append(':') 170 .append(extension); 171 172 return buffer.toString(); 173 } 174 }