View Javadoc
1   package org.eclipse.aether.spi.connector.transport;
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 java.net.URI;
23  import static java.util.Objects.requireNonNull;
24  
25  /**
26   * A transport task.
27   *
28   * @noextend This class is not intended to be extended by clients.
29   */
30  public abstract class TransportTask
31  {
32  
33      static final TransportListener NOOP = new TransportListener()
34      {
35      };
36  
37      static final byte[] EMPTY = {};
38  
39      private URI location;
40  
41      private TransportListener listener = NOOP;
42  
43      TransportTask()
44      {
45          // hide
46      }
47  
48      /**
49       * Gets the relative location of the affected resource in the remote repository.
50       * 
51       * @return The relative location of the resource, never {@code null}.
52       */
53      public URI getLocation()
54      {
55          return location;
56      }
57  
58      TransportTask setLocation( URI location )
59      {
60          this.location = requireNonNull( location, "location type cannot be null" );
61          return this;
62      }
63  
64      /**
65       * Gets the listener that is to be notified during the transfer.
66       *
67       * @return The listener to notify of progress, never {@code null}.
68       */
69      public TransportListener getListener()
70      {
71          return listener;
72      }
73  
74      /**
75       * Sets the listener that is to be notified during the transfer.
76       * 
77       * @param listener The listener to notify of progress, may be {@code null}.
78       * @return This task for chaining, never {@code null}.
79       */
80      TransportTask setListener( TransportListener listener )
81      {
82          this.listener = ( listener != null ) ? listener : NOOP;
83          return this;
84      }
85  
86  }