View Javadoc

1   /*
2    * Copyright 2012 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.Arguments;
19  import de.smartics.util.lang.BlankArgumentException;
20  
21  /**
22   * The data to send to the Nexus server to access artifact resolution
23   * information.
24   */
25  public final class NexusRequest
26  {
27    // ********************************* Fields *********************************
28  
29    // --- constants ------------------------------------------------------------
30  
31    // --- members --------------------------------------------------------------
32  
33    /**
34     * The path to the Nexus server.
35     */
36    private final String nexusServer;
37  
38    /**
39     * The identifier of the repository to query on the given nexus server.
40     */
41    private final String repositoryId;
42  
43    /**
44     * The group identifier of the requested artifact.
45     */
46    private final String groupId;
47  
48    /**
49     * The identifier of the requested artifact.
50     */
51    private final String artifactId;
52  
53    // ****************************** Initializer *******************************
54  
55    // ****************************** Constructors ******************************
56  
57    /**
58     * Default constructor.
59     *
60     * @param nexusServer the path to the Nexus server.
61     * @param repositoryId the identifier of the repository to query on the given
62     *          nexus server.
63     * @param groupId the group identifier of the requested artifact.
64     * @param artifactId the identifier of the requested artifact.
65     * @throws BlankArgumentException if any parameter value is blank.
66     */
67    public NexusRequest(final String nexusServer, final String repositoryId,
68        final String groupId, final String artifactId)
69      throws BlankArgumentException
70    {
71      Arguments.checkNotBlank("nexusServer", nexusServer);
72      Arguments.checkNotBlank("repositoryId", repositoryId);
73      Arguments.checkNotBlank("groupId", groupId);
74      Arguments.checkNotBlank("artifactId", artifactId);
75  
76      this.nexusServer = nexusServer;
77      this.repositoryId = repositoryId;
78      this.groupId = groupId;
79      this.artifactId = artifactId;
80    }
81  
82    // ****************************** Inner Classes *****************************
83  
84    // ********************************* Methods ********************************
85  
86    // --- init -----------------------------------------------------------------
87  
88    // --- get&set --------------------------------------------------------------
89  
90    /**
91     * Returns the path to the Nexus server.
92     *
93     * @return the path to the Nexus server.
94     */
95    public String getNexusServer()
96    {
97      return nexusServer;
98    }
99  
100   /**
101    * Returns the identifier of the repository to query on the given nexus
102    * server.
103    *
104    * @return the identifier of the repository to query on the given nexus
105    *         server.
106    */
107   public String getRepositoryId()
108   {
109     return repositoryId;
110   }
111 
112   /**
113    * Returns the group identifier of the requested artifact.
114    *
115    * @return the group identifier of the requested artifact.
116    */
117   public String getGroupId()
118   {
119     return groupId;
120   }
121 
122   /**
123    * Returns the identifier of the requested artifact.
124    *
125    * @return the identifier of the requested artifact.
126    */
127   public String getArtifactId()
128   {
129     return artifactId;
130   }
131 
132   // --- business -------------------------------------------------------------
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   // --- object basics --------------------------------------------------------
145 
146   /**
147    * Returns the string representation of the object.
148    *
149    * @return the string representation of the object.
150    */
151   @Override
152   public String toString()
153   {
154     final StringBuilder buffer = new StringBuilder();
155 
156     buffer.append(nexusServer).append(':').append(repositoryId).append(':')
157         .append(groupId).append(':').append(artifactId);
158 
159     return buffer.toString();
160   }
161 }