View Javadoc
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.eclipse.aether.resolution;
20  
21  import org.eclipse.aether.artifact.Artifact;
22  
23  /**
24   * A query for the error policy for a given artifact's descriptor.
25   *
26   * @see ArtifactDescriptorPolicy
27   */
28  public final class ArtifactDescriptorPolicyRequest {
29  
30      private Artifact artifact;
31  
32      private String context = "";
33  
34      /**
35       * Creates an uninitialized request.
36       */
37      public ArtifactDescriptorPolicyRequest() {
38          // enables default constructor
39      }
40  
41      /**
42       * Creates a request for the specified artifact.
43       *
44       * @param artifact The artifact for whose descriptor to determine the error policy, may be {@code null}.
45       * @param context The context in which this request is made, may be {@code null}.
46       */
47      public ArtifactDescriptorPolicyRequest(Artifact artifact, String context) {
48          setArtifact(artifact);
49          setRequestContext(context);
50      }
51  
52      /**
53       * Gets the artifact for whose descriptor to determine the error policy.
54       *
55       * @return The artifact for whose descriptor to determine the error policy or {@code null} if not set.
56       */
57      public Artifact getArtifact() {
58          return artifact;
59      }
60  
61      /**
62       * Sets the artifact for whose descriptor to determine the error policy.
63       *
64       * @param artifact The artifact for whose descriptor to determine the error policy, may be {@code null}.
65       * @return This request for chaining, never {@code null}.
66       */
67      public ArtifactDescriptorPolicyRequest setArtifact(Artifact artifact) {
68          this.artifact = artifact;
69          return this;
70      }
71  
72      /**
73       * Gets the context in which this request is made.
74       *
75       * @return The context, never {@code null}.
76       */
77      public String getRequestContext() {
78          return context;
79      }
80  
81      /**
82       * Sets the context in which this request is made.
83       *
84       * @param context The context, may be {@code null}.
85       * @return This request for chaining, never {@code null}.
86       */
87      public ArtifactDescriptorPolicyRequest setRequestContext(String context) {
88          this.context = (context != null) ? context : "";
89          return this;
90      }
91  
92      @Override
93      public String toString() {
94          return String.valueOf(getArtifact());
95      }
96  }