View Javadoc
1   /*******************************************************************************
2    * Copyright (c) 2012 Sonatype, Inc.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the Eclipse Public License v1.0
5    * which accompanies this distribution, and is available at
6    * http://www.eclipse.org/legal/epl-v10.html
7    *
8    * Contributors:
9    *    Sonatype, Inc. - initial API and implementation
10   *******************************************************************************/
11  package org.eclipse.aether.resolution;
12  
13  import org.eclipse.aether.artifact.Artifact;
14  
15  /**
16   * A query for the error policy for a given artifact's descriptor.
17   * 
18   * @see ArtifactDescriptorPolicy
19   */
20  public final class ArtifactDescriptorPolicyRequest
21  {
22  
23      private Artifact artifact;
24  
25      private String context = "";
26  
27      /**
28       * Creates an uninitialized request.
29       */
30      public ArtifactDescriptorPolicyRequest()
31      {
32          // enables default constructor
33      }
34  
35      /**
36       * Creates a request for the specified artifact.
37       * 
38       * @param artifact The artifact for whose descriptor to determine the error policy, may be {@code null}.
39       * @param context The context in which this request is made, may be {@code null}.
40       */
41      public ArtifactDescriptorPolicyRequest( Artifact artifact, String context )
42      {
43          setArtifact( artifact );
44          setRequestContext( context );
45      }
46  
47      /**
48       * Gets the artifact for whose descriptor to determine the error policy.
49       * 
50       * @return The artifact for whose descriptor to determine the error policy or {@code null} if not set.
51       */
52      public Artifact getArtifact()
53      {
54          return artifact;
55      }
56  
57      /**
58       * Sets the artifact for whose descriptor to determine the error policy.
59       * 
60       * @param artifact The artifact for whose descriptor to determine the error policy, may be {@code null}.
61       * @return This request for chaining, never {@code null}.
62       */
63      public ArtifactDescriptorPolicyRequest setArtifact( Artifact artifact )
64      {
65          this.artifact = artifact;
66          return this;
67      }
68  
69      /**
70       * Gets the context in which this request is made.
71       * 
72       * @return The context, never {@code null}.
73       */
74      public String getRequestContext()
75      {
76          return context;
77      }
78  
79      /**
80       * Sets the context in which this request is made.
81       * 
82       * @param context The context, may be {@code null}.
83       * @return This request for chaining, never {@code null}.
84       */
85      public ArtifactDescriptorPolicyRequest setRequestContext( String context )
86      {
87          this.context = ( context != null ) ? context : "";
88          return this;
89      }
90  
91      @Override
92      public String toString()
93      {
94          return String.valueOf( getArtifact() );
95      }
96  
97  }