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.repository.RemoteRepository;
14  
15  /**
16   * A query for the resolution error policy for a given artifact/metadata.
17   * 
18   * @param <T> The type of the affected repository item (artifact or metadata).
19   * @see ResolutionErrorPolicy
20   */
21  public final class ResolutionErrorPolicyRequest<T>
22  {
23  
24      private T item;
25  
26      private RemoteRepository repository;
27  
28      /**
29       * Creates an uninitialized request.
30       */
31      public ResolutionErrorPolicyRequest()
32      {
33          // enables default constructor
34      }
35  
36      /**
37       * Creates a request for the specified artifact/metadata and remote repository.
38       * 
39       * @param item The artifact/metadata for which to determine the error policy, may be {@code null}.
40       * @param repository The repository from which the resolution is attempted, may be {@code null}.
41       */
42      public ResolutionErrorPolicyRequest( T item, RemoteRepository repository )
43      {
44          setItem( item );
45          setRepository( repository );
46      }
47  
48      /**
49       * Gets the artifact/metadata for which to determine the error policy.
50       * 
51       * @return The artifact/metadata for which to determine the error policy or {@code null} if not set.
52       */
53      public T getItem()
54      {
55          return item;
56      }
57  
58      /**
59       * Sets the artifact/metadata for which to determine the error policy.
60       * 
61       * @param item The artifact/metadata for which to determine the error policy, may be {@code null}.
62       * @return This request for chaining, never {@code null}.
63       */
64      public ResolutionErrorPolicyRequest<T> setItem( T item )
65      {
66          this.item = item;
67          return this;
68      }
69  
70      /**
71       * Gets the remote repository from which the resolution of the artifact/metadata is attempted.
72       * 
73       * @return The involved remote repository or {@code null} if not set.
74       */
75      public RemoteRepository getRepository()
76      {
77          return repository;
78      }
79  
80      /**
81       * Sets the remote repository from which the resolution of the artifact/metadata is attempted.
82       * 
83       * @param repository The repository from which the resolution is attempted, may be {@code null}.
84       * @return This request for chaining, never {@code null}.
85       */
86      public ResolutionErrorPolicyRequest<T> setRepository( RemoteRepository repository )
87      {
88          this.repository = repository;
89          return this;
90      }
91  
92      @Override
93      public String toString()
94      {
95          return getItem() + " < " + getRepository();
96      }
97  
98  }