1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-10 17:49:38 +02:00

Generify Packet class returned by PackageCollector everywhere

This will help to get rid of repetitive class casts, and make
PacketCollector api more inline with itself (since some methods
are already generic return methods).
This commit is contained in:
Vyacheslav Blinov 2014-08-15 12:49:05 +04:00 committed by Florian Schmaus
parent b3b0e02ae1
commit 522d0f30ff
5 changed files with 17 additions and 15 deletions

View file

@ -103,8 +103,9 @@ public class PacketCollector {
* @return the next packet result, or <tt>null</tt> if there are no more
* results.
*/
public Packet pollResult() {
return resultQueue.poll();
@SuppressWarnings("unchecked")
public <P extends Packet> P pollResult() {
return (P) resultQueue.poll();
}
/**
@ -113,9 +114,10 @@ public class PacketCollector {
*
* @return the next available packet.
*/
public Packet nextResultBlockForever() {
@SuppressWarnings("unchecked")
public <P extends Packet> P nextResultBlockForever() {
try {
return resultQueue.take();
return (P) resultQueue.take();
}
catch (InterruptedException e) {
throw new RuntimeException(e);
@ -128,7 +130,7 @@ public class PacketCollector {
*
* @return the next availabe packet.
*/
public Packet nextResult() {
public <P extends Packet> P nextResult() {
return nextResult(connection.getPacketReplyTimeout());
}