001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.eclipse.aether.spi.connector;
020
021import org.eclipse.aether.RequestTrace;
022import org.eclipse.aether.transfer.TransferListener;
023
024/**
025 * An artifact/metadata transfer.
026 *
027 * @noextend This class is not intended to be extended by clients.
028 */
029public abstract class Transfer {
030
031    private TransferListener listener;
032
033    private RequestTrace trace;
034
035    Transfer() {
036        // hide from public
037    }
038
039    /**
040     * Gets the exception that occurred during the transfer (if any).
041     *
042     * @return The exception or {@code null} if the transfer was successful.
043     */
044    public abstract Exception getException();
045
046    /**
047     * Gets the listener that is to be notified during the transfer.
048     *
049     * @return The transfer listener or {@code null} if none.
050     */
051    public TransferListener getListener() {
052        return listener;
053    }
054
055    /**
056     * Sets the listener that is to be notified during the transfer.
057     *
058     * @param listener The transfer listener to notify, may be {@code null} if none.
059     * @return This transfer for chaining, never {@code null}.
060     */
061    Transfer setListener(TransferListener listener) {
062        this.listener = listener;
063        return this;
064    }
065
066    /**
067     * Gets the trace information that describes the higher level request/operation in which this transfer is issued.
068     *
069     * @return The trace information about the higher level operation or {@code null} if none.
070     */
071    public RequestTrace getTrace() {
072        return trace;
073    }
074
075    /**
076     * Sets the trace information that describes the higher level request/operation in which this transfer is issued.
077     *
078     * @param trace The trace information about the higher level operation, may be {@code null}.
079     * @return This transfer for chaining, never {@code null}.
080     */
081    Transfer setTrace(RequestTrace trace) {
082        this.trace = trace;
083        return this;
084    }
085}