Removed functions from Endpoint.IdResolver

In my use-cases there should be a preexisting struct already
IdResolver should just be an accessor to that struct and not a mutator
This commit is contained in:
Collin Smith
2020-06-28 18:49:11 -07:00
parent 60257b48de
commit 1af1fd968e
3 changed files with 5 additions and 24 deletions

View File

@ -11,7 +11,5 @@ public interface Endpoint<T> {
interface IdResolver<R> {
R get(int id);
R put(int id, R ch);
R remove(int id);
}
}

View File

@ -75,16 +75,6 @@ public class Server implements PacketProcessor {
return clients[id].channel;
}
@Override
public Channel put(int id, Channel ch) {
throw new UnsupportedOperationException();
}
@Override
public Channel remove(int id) {
throw new UnsupportedOperationException();
}
@Override
public String toString() {
return ArrayUtils.toString(clients);

View File

@ -4,6 +4,11 @@ import io.netty.channel.Channel;
import com.riiablo.nnet.Endpoint;
/**
* Not used anymore -- prefer to use anonymous implementations of {@link Endpoint.IdResolver} which
* wrap preexisting data structures.
*/
@Deprecated
public class ChannelIdResolver implements Endpoint.IdResolver<Channel> {
private final Channel[] channels;
@ -15,16 +20,4 @@ public class ChannelIdResolver implements Endpoint.IdResolver<Channel> {
public Channel get(int id) {
return channels[id];
}
@Override
public Channel put(int id, Channel ch) {
Channel oldValue = channels[id];
channels[id] = ch;
return oldValue;
}
@Override
public Channel remove(int id) {
return put(id, null);
}
}