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