bt.protocol.handler.UniqueMessageHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bt-core Show documentation
Show all versions of bt-core Show documentation
BitTorrent Client Library (Core)
package bt.protocol.handler;
import bt.protocol.Message;
import java.nio.ByteBuffer;
import java.util.Collection;
import java.util.Collections;
abstract class UniqueMessageHandler extends BaseMessageHandler {
private Class type;
private Collection> supportedTypes;
protected UniqueMessageHandler(Class type) {
this.type = type;
supportedTypes = Collections.singleton(type);
}
@Override
public Collection> getSupportedTypes() {
return supportedTypes;
}
@Override
public Class extends T> readMessageType(ByteBuffer buffer) {
return type;
}
}