All Downloads are FREE. Search and download functionalities are using the official Maven repository.

bt.torrent.TorrentRegistry Maven / Gradle / Ivy

There is a newer version: 1.10
Show newest version
package bt.torrent;

import bt.data.Storage;
import bt.metainfo.Torrent;
import bt.metainfo.TorrentId;

import java.util.Collection;
import java.util.Optional;

/**
 * Registry of all torrents known to the current runtime.
 *
 * @since 1.0
 */
public interface TorrentRegistry {

    /**
     * Get all torrents, that have been registered in the runtime.
     *
     * @return All registered torrents
     * @since 1.2
     */
    Collection getTorrents();

    /**
     * Get all torrents, that have been registered in the runtime.
     *
     * @return All registered torrents
     * @since 1.3
     */
    Collection getTorrentIds();

    /**
     * Get a torrent with a given torrent ID, if exists.
     *
     * @return {@link Optional#empty()} if this torrent ID is not known to the current runtime.
     * @since 1.0
     */
    Optional getTorrent(TorrentId torrentId);

    /**
     * Get a torrent descriptor for a given torrent, if exists.
     *
     * @return {@link Optional#empty()} if torrent descriptor hasn't been created yet.
     * @since 1.0
     * @deprecated since 1.3 in favor of {@link #getDescriptor(TorrentId)}
     */
    Optional getDescriptor(Torrent torrent);

    /**
     * Get a torrent descriptor for a given torrent, if exists.
     *
     * @return {@link Optional#empty()} if torrent descriptor hasn't been created yet.
     * @since 1.3
     */
    Optional getDescriptor(TorrentId torrentId);

    /**
     * Get an existing torrent descriptor for a given torrent
     * or create a new one if it does not exist.
     *
     * @param storage Storage to use for storing this torrent's files.
     *                Will be used when creating a new torrent descriptor.
     * @return Torrent descriptor
     * @since 1.0
     * @deprecated since 1.3 in favor of more clearly named {@link #register(Torrent, Storage)}
     */
    TorrentDescriptor getOrCreateDescriptor(Torrent torrent, Storage storage);

    /**
     * Get an existing torrent descriptor for a given torrent
     * or create a new one if it does not exist.
     *
     * @param storage Storage to use for storing this torrent's files.
     *                Will be used when creating a new torrent descriptor.
     * @return Torrent descriptor
     * @since 1.3
     */
    TorrentDescriptor register(Torrent torrent, Storage storage);

    /**
     * Get an existing torrent descriptor for a given torrent ID
     * or create a new one if it does not exist.
     *
     * @return Torrent descriptor
     * @since 1.3
     */
    TorrentDescriptor register(TorrentId torrentId);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy