summaryrefslogtreecommitdiff
path: root/src/main/java/net/transit/network/swap/IProvider.java
blob: 03c9ca9d0848be2a3413547f6e84cf0e60ecae42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package net.transit.network.swap;

import net.transit.network.packet.IPacket;

/**
 * @author Kyle Gunger
 *
 * @param <T> The type of data provided (in IPacket<<T>> form)
 */
public interface IProvider<T>
{
    /**
     * @return <b>True</b> if the provider can provide a packet.
     */
    public boolean canProvide();

    /**Get the next packet from the provider
     * 
     * @return IPacket<<T>>
     */
    public IPacket<T> provide();
    
    /**Retain the packet if the acceptor did not accept the packet.
     * 
     * @param rejected The rejected packet
     */
    public void retain(IPacket<T> rejected);
    
    /**
     * @return <b>True</b> if the acceptor has a provider assigned to it
     */
    public boolean hasAcceptor();
    
    /**Set the acceptor of the provider. The provider can decide if it wants to adopt the acceptor.
     */
    public void setAcceptor();
}