View Javadoc
1   package org.eclipse.aether.resolution;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   * 
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   * 
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.eclipse.aether.artifact.Artifact;
23  
24  /**
25   * A query for the error policy for a given artifact's descriptor.
26   * 
27   * @see ArtifactDescriptorPolicy
28   */
29  public final class ArtifactDescriptorPolicyRequest
30  {
31  
32      private Artifact artifact;
33  
34      private String context = "";
35  
36      /**
37       * Creates an uninitialized request.
38       */
39      public ArtifactDescriptorPolicyRequest()
40      {
41          // enables default constructor
42      }
43  
44      /**
45       * Creates a request for the specified artifact.
46       * 
47       * @param artifact The artifact for whose descriptor to determine the error policy, may be {@code null}.
48       * @param context The context in which this request is made, may be {@code null}.
49       */
50      public ArtifactDescriptorPolicyRequest( Artifact artifact, String context )
51      {
52          setArtifact( artifact );
53          setRequestContext( context );
54      }
55  
56      /**
57       * Gets the artifact for whose descriptor to determine the error policy.
58       * 
59       * @return The artifact for whose descriptor to determine the error policy or {@code null} if not set.
60       */
61      public Artifact getArtifact()
62      {
63          return artifact;
64      }
65  
66      /**
67       * Sets the artifact for whose descriptor to determine the error policy.
68       * 
69       * @param artifact The artifact for whose descriptor to determine the error policy, may be {@code null}.
70       * @return This request for chaining, never {@code null}.
71       */
72      public ArtifactDescriptorPolicyRequest setArtifact( Artifact artifact )
73      {
74          this.artifact = artifact;
75          return this;
76      }
77  
78      /**
79       * Gets the context in which this request is made.
80       * 
81       * @return The context, never {@code null}.
82       */
83      public String getRequestContext()
84      {
85          return context;
86      }
87  
88      /**
89       * Sets the context in which this request is made.
90       * 
91       * @param context The context, may be {@code null}.
92       * @return This request for chaining, never {@code null}.
93       */
94      public ArtifactDescriptorPolicyRequest setRequestContext( String context )
95      {
96          this.context = ( context != null ) ? context : "";
97          return this;
98      }
99  
100     @Override
101     public String toString()
102     {
103         return String.valueOf( getArtifact() );
104     }
105 
106 }