From 06fd5e9845fb37d112296d1989073c0725da62f6 Mon Sep 17 00:00:00 2001 From: Dave Date: Sun, 5 Jul 2015 18:57:25 +0200 Subject: [PATCH] changed byteSet from Collection to List so as to iterate by index --- src/nodash/core/NoAdapter.java | 5 +++-- src/nodash/core/NoDefaultAdapter.java | 18 +++++++++--------- src/nodash/models/NoSession.java | 6 +++--- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/nodash/core/NoAdapter.java b/src/nodash/core/NoAdapter.java index f85b1c9..185b900 100644 --- a/src/nodash/core/NoAdapter.java +++ b/src/nodash/core/NoAdapter.java @@ -19,6 +19,7 @@ package nodash.core; import java.security.PublicKey; import java.util.Collection; +import java.util.List; import nodash.exceptions.NoAdapterException; import nodash.exceptions.NoSessionExpiredException; @@ -148,7 +149,7 @@ public interface NoAdapter { * should return an empty collection, not a null object. * @throws NoAdapterException */ - public Collection pollNoByteSets(PublicKey address) throws NoAdapterException; + public List pollNoByteSets(PublicKey address) throws NoAdapterException; /** * Adds a single NoByteSet to the addressed PublicKey address. @@ -167,6 +168,6 @@ public interface NoAdapter { * @throws NoAdapterException - if the adapter is unable to add the list of NoByteSet objects to * the pool. */ - public void addNoByteSets(Collection byteSets, PublicKey address) + public void addNoByteSets(List byteSets, PublicKey address) throws NoAdapterException; } diff --git a/src/nodash/core/NoDefaultAdapter.java b/src/nodash/core/NoDefaultAdapter.java index 9106cd0..e06dbea 100644 --- a/src/nodash/core/NoDefaultAdapter.java +++ b/src/nodash/core/NoDefaultAdapter.java @@ -43,8 +43,8 @@ import nodash.models.NoByteSet; import nodash.models.NoSession; public class NoDefaultAdapter implements NoAdapter { - private static Map> byteSets = - new ConcurrentHashMap>(); + private static Map> byteSets = + new ConcurrentHashMap>(); private static Map sessions = new ConcurrentHashMap(); private static Set online = Collections .newSetFromMap(new ConcurrentHashMap()); @@ -200,13 +200,13 @@ public class NoDefaultAdapter implements NoAdapter { } @Override - public Collection pollNoByteSets(PublicKey address) { + public List pollNoByteSets(PublicKey address) { if (byteSets.containsKey(address)) { - Collection storedByteSets = byteSets.get(address); - Collection result = new ArrayList(); - for (NoByteSet byteSet : storedByteSets) { - result.add(byteSet); - storedByteSets.remove(byteSet); + List storedByteSets = byteSets.get(address); + List result = new ArrayList(); + for (int x = 0; x < storedByteSets.size(); x++) { + result.add(storedByteSets.get(0)); + storedByteSets.remove(0); } return result; } else { @@ -223,7 +223,7 @@ public class NoDefaultAdapter implements NoAdapter { } @Override - public void addNoByteSets(Collection addedByteSets, PublicKey address) { + public void addNoByteSets(List addedByteSets, PublicKey address) { if (addedByteSets == null) { return; } diff --git a/src/nodash/models/NoSession.java b/src/nodash/models/NoSession.java index 9d0e91d..dddf772 100644 --- a/src/nodash/models/NoSession.java +++ b/src/nodash/models/NoSession.java @@ -34,7 +34,7 @@ public final class NoSession implements Serializable { private NoState state; private final long expiry; - private Collection incoming; + private List incoming; private NoUser current; private String uuid; @@ -173,7 +173,7 @@ public final class NoSession implements Serializable { return this.incoming; } - public Collection getIncomingSafe() { + public List getIncomingSafe() { return this.incoming; } @@ -193,7 +193,7 @@ public final class NoSession implements Serializable { } } - public void setIncoming(Collection incoming) { + public void setIncoming(List incoming) { this.incoming = incoming; }