Package org.johnnei.javatorrent.phases
Class PhaseRegulator.Builder
- java.lang.Object
-
- org.johnnei.javatorrent.phases.PhaseRegulator.Builder
-
- Enclosing class:
- PhaseRegulator
public static class PhaseRegulator.Builder extends Object
A builder-pattern styled class to created thePhaseRegulatorconfiguration.
-
-
Constructor Summary
Constructors Constructor Description Builder()Creates a newPhaseRegulator.Builderinstance without anyIDownloadPhaseconfigured.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PhaseRegulatorbuild()<T extends IDownloadPhase>
PhaseRegulator.BuilderregisterInitialPhase(Class<T> phase, BiFunction<TorrentClient,Torrent,T> phaseSupplier)Registers the initialIDownloadPhase<T extends IDownloadPhase>
PhaseRegulator.BuilderregisterInitialPhase(Class<T> phase, BiFunction<TorrentClient,Torrent,T> phaseSupplier, Class<? extends IDownloadPhase> nextPhase)Registers the initialIDownloadPhase<T extends IDownloadPhase>
PhaseRegulator.BuilderregisterPhase(Class<T> phase, BiFunction<TorrentClient,Torrent,T> phaseSupplier)Registers a new transition to the givenIDownloadPhase<T extends IDownloadPhase>
PhaseRegulator.BuilderregisterPhase(Class<T> phase, BiFunction<TorrentClient,Torrent,T> phaseSupplier, Class<? extends IDownloadPhase> nextPhase)Registers a new transition to the givenIDownloadPhase
-
-
-
Constructor Detail
-
Builder
public Builder()
Creates a newPhaseRegulator.Builderinstance without anyIDownloadPhaseconfigured.
-
-
Method Detail
-
registerInitialPhase
public <T extends IDownloadPhase> PhaseRegulator.Builder registerInitialPhase(Class<T> phase, BiFunction<TorrentClient,Torrent,T> phaseSupplier)
Registers the initialIDownloadPhase- Type Parameters:
T- The type of theIDownloadPhase- Parameters:
phase- The initial phasephaseSupplier- TheBiFunctionwhich is capable of creating phase instances.- Returns:
- This
PhaseRegulator.Builderwith updated configuration.
-
registerInitialPhase
public <T extends IDownloadPhase> PhaseRegulator.Builder registerInitialPhase(Class<T> phase, BiFunction<TorrentClient,Torrent,T> phaseSupplier, Class<? extends IDownloadPhase> nextPhase)
Registers the initialIDownloadPhase- Type Parameters:
T- The type of theIDownloadPhase- Parameters:
phase- The initial phasephaseSupplier- TheBiFunctionwhich is capable of creating phase instances.nextPhase- The phase to transition to whenphasehas completed.- Returns:
- This
PhaseRegulator.Builderwith updated configuration.
-
registerPhase
public <T extends IDownloadPhase> PhaseRegulator.Builder registerPhase(Class<T> phase, BiFunction<TorrentClient,Torrent,T> phaseSupplier)
Registers a new transition to the givenIDownloadPhase- Type Parameters:
T- The type of theIDownloadPhase- Parameters:
phase- The phase from which the transition happens.phaseSupplier- TheBiFunctionwhich is capable of creating phase instances.- Returns:
- This
PhaseRegulator.Builderwith updated configuration.
-
registerPhase
public <T extends IDownloadPhase> PhaseRegulator.Builder registerPhase(Class<T> phase, BiFunction<TorrentClient,Torrent,T> phaseSupplier, Class<? extends IDownloadPhase> nextPhase)
Registers a new transition to the givenIDownloadPhase- Type Parameters:
T- The type of theIDownloadPhase- Parameters:
phase- The phase from which the transition happens.phaseSupplier- TheBiFunctionwhich is capable of creating phase instances.nextPhase- The phase to transition to whenphasehas completed.- Returns:
- This
PhaseRegulator.Builderwith updated configuration.
-
build
public PhaseRegulator build()
- Returns:
- The newly created configured instance of
PhaseRegulator
-
-