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.spi.connector;
20  
21  import org.eclipse.aether.RequestTrace;
22  import org.eclipse.aether.transfer.TransferListener;
23  
24  /**
25   * An artifact/metadata transfer.
26   *
27   * @noextend This class is not intended to be extended by clients.
28   */
29  public abstract class Transfer {
30  
31      private TransferListener listener;
32  
33      private RequestTrace trace;
34  
35      Transfer() {
36          // hide from public
37      }
38  
39      /**
40       * Gets the exception that occurred during the transfer (if any).
41       *
42       * @return The exception or {@code null} if the transfer was successful.
43       */
44      public abstract Exception getException();
45  
46      /**
47       * Gets the listener that is to be notified during the transfer.
48       *
49       * @return The transfer listener or {@code null} if none.
50       */
51      public TransferListener getListener() {
52          return listener;
53      }
54  
55      /**
56       * Sets the listener that is to be notified during the transfer.
57       *
58       * @param listener The transfer listener to notify, may be {@code null} if none.
59       * @return This transfer for chaining, never {@code null}.
60       */
61      Transfer setListener(TransferListener listener) {
62          this.listener = listener;
63          return this;
64      }
65  
66      /**
67       * Gets the trace information that describes the higher level request/operation in which this transfer is issued.
68       *
69       * @return The trace information about the higher level operation or {@code null} if none.
70       */
71      public RequestTrace getTrace() {
72          return trace;
73      }
74  
75      /**
76       * Sets the trace information that describes the higher level request/operation in which this transfer is issued.
77       *
78       * @param trace The trace information about the higher level operation, may be {@code null}.
79       * @return This transfer for chaining, never {@code null}.
80       */
81      Transfer setTrace(RequestTrace trace) {
82          this.trace = trace;
83          return this;
84      }
85  }