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