001package org.eclipse.aether.spi.connector.transport; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import java.net.URI; 023import static java.util.Objects.requireNonNull; 024 025/** 026 * A transport task. 027 * 028 * @noextend This class is not intended to be extended by clients. 029 */ 030public abstract class TransportTask 031{ 032 033 static final TransportListener NOOP = new TransportListener() 034 { 035 }; 036 037 static final byte[] EMPTY = {}; 038 039 private URI location; 040 041 private TransportListener listener = NOOP; 042 043 TransportTask() 044 { 045 // hide 046 } 047 048 /** 049 * Gets the relative location of the affected resource in the remote repository. 050 * 051 * @return The relative location of the resource, never {@code null}. 052 */ 053 public URI getLocation() 054 { 055 return location; 056 } 057 058 TransportTask setLocation( URI location ) 059 { 060 this.location = requireNonNull( location, "location type cannot be null" ); 061 return this; 062 } 063 064 /** 065 * Gets the listener that is to be notified during the transfer. 066 * 067 * @return The listener to notify of progress, never {@code null}. 068 */ 069 public TransportListener getListener() 070 { 071 return listener; 072 } 073 074 /** 075 * Sets the listener that is to be notified during the transfer. 076 * 077 * @param listener The listener to notify of progress, may be {@code null}. 078 * @return This task for chaining, never {@code null}. 079 */ 080 TransportTask setListener( TransportListener listener ) 081 { 082 this.listener = ( listener != null ) ? listener : NOOP; 083 return this; 084 } 085 086}