mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 03:09:04 +01:00
Remove unnecessary unmodifiable collection wrappers.
This commit is contained in:
@@ -396,7 +396,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
||||
blogs.add(b);
|
||||
}
|
||||
}
|
||||
return Collections.unmodifiableList(blogs);
|
||||
return blogs;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -419,7 +419,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
||||
} finally {
|
||||
db.endTransaction(txn);
|
||||
}
|
||||
return Collections.unmodifiableList(blogs);
|
||||
return blogs;
|
||||
} catch (FormatException e) {
|
||||
throw new DbException(e);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@@ -208,7 +207,7 @@ class ClientHelperImpl implements ClientHelper {
|
||||
new HashMap<MessageId, BdfDictionary>(raw.size());
|
||||
for (Entry<MessageId, Metadata> e : raw.entrySet())
|
||||
parsed.put(e.getKey(), metadataParser.parse(e.getValue()));
|
||||
return Collections.unmodifiableMap(parsed);
|
||||
return parsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -236,7 +235,7 @@ class ClientHelperImpl implements ClientHelper {
|
||||
new HashMap<MessageId, BdfDictionary>(raw.size());
|
||||
for (Entry<MessageId, Metadata> e : raw.entrySet())
|
||||
parsed.put(e.getKey(), metadataParser.parse(e.getValue()));
|
||||
return Collections.unmodifiableMap(parsed);
|
||||
return parsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -103,7 +103,7 @@ public class MessageTreeImpl<T extends MessageTree.MessageNode>
|
||||
for (T root : roots) {
|
||||
traverse(orderedList, root, 0);
|
||||
}
|
||||
return Collections.unmodifiableList(orderedList);
|
||||
return orderedList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -329,7 +329,7 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
|
||||
if (ids.isEmpty()) return null;
|
||||
db.lowerRequestedFlag(txn, c, ids);
|
||||
transaction.attach(new MessagesSentEvent(c, ids));
|
||||
return Collections.unmodifiableList(messages);
|
||||
return messages;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -379,7 +379,7 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
|
||||
if (ids.isEmpty()) return null;
|
||||
db.lowerRequestedFlag(txn, c, ids);
|
||||
transaction.attach(new MessagesSentEvent(c, ids));
|
||||
return Collections.unmodifiableList(messages);
|
||||
return messages;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -199,7 +199,7 @@ class ForumManagerImpl extends BdfIncomingMessageHook implements ForumManager {
|
||||
}
|
||||
List<Forum> forums = new ArrayList<Forum>();
|
||||
for (Group g : groups) forums.add(parseForum(g));
|
||||
return Collections.unmodifiableList(forums);
|
||||
return forums;
|
||||
} catch (FormatException e) {
|
||||
throw new DbException(e);
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
|
||||
contactCounts = new HashMap<ContactId, Integer>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerConnection(ContactId c, TransportId t,
|
||||
boolean incoming) {
|
||||
if (LOG.isLoggable(INFO)) {
|
||||
@@ -76,6 +77,7 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterConnection(ContactId c, TransportId t,
|
||||
boolean incoming) {
|
||||
if (LOG.isLoggable(INFO)) {
|
||||
@@ -112,6 +114,7 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ContactId> getConnectedContacts(TransportId t) {
|
||||
lock.lock();
|
||||
try {
|
||||
@@ -120,12 +123,13 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
|
||||
List<ContactId> ids = new ArrayList<ContactId>(m.keySet());
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info(ids.size() + " contacts connected");
|
||||
return Collections.unmodifiableList(ids);
|
||||
return ids;
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnected(ContactId c, TransportId t) {
|
||||
lock.lock();
|
||||
try {
|
||||
@@ -136,6 +140,7 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnected(ContactId c) {
|
||||
lock.lock();
|
||||
try {
|
||||
|
||||
@@ -156,12 +156,12 @@ class PluginManagerImpl implements PluginManager, Service {
|
||||
|
||||
@Override
|
||||
public Collection<SimplexPlugin> getSimplexPlugins() {
|
||||
return Collections.unmodifiableList(simplexPlugins);
|
||||
return new ArrayList<SimplexPlugin>(simplexPlugins);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<DuplexPlugin> getDuplexPlugins() {
|
||||
return Collections.unmodifiableList(duplexPlugins);
|
||||
return new ArrayList<DuplexPlugin>(duplexPlugins);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -169,7 +169,7 @@ class PluginManagerImpl implements PluginManager, Service {
|
||||
List<DuplexPlugin> supported = new ArrayList<DuplexPlugin>();
|
||||
for (DuplexPlugin d : duplexPlugins)
|
||||
if (d.supportsInvitations()) supported.add(d);
|
||||
return Collections.unmodifiableList(supported);
|
||||
return supported;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -177,7 +177,7 @@ class PluginManagerImpl implements PluginManager, Service {
|
||||
List<DuplexPlugin> supported = new ArrayList<DuplexPlugin>();
|
||||
for (DuplexPlugin d : duplexPlugins)
|
||||
if (d.supportsKeyAgreement()) supported.add(d);
|
||||
return Collections.unmodifiableList(supported);
|
||||
return supported;
|
||||
}
|
||||
|
||||
private class PluginStarter implements Runnable {
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.briarproject.api.sync.Message;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
import org.briarproject.api.system.Clock;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@@ -101,7 +100,7 @@ class TransportPropertyManagerImpl implements TransportPropertyManager,
|
||||
} finally {
|
||||
db.endTransaction(txn);
|
||||
}
|
||||
return Collections.unmodifiableMap(local);
|
||||
return local;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -176,7 +175,7 @@ class TransportPropertyManagerImpl implements TransportPropertyManager,
|
||||
} finally {
|
||||
db.endTransaction(txn);
|
||||
}
|
||||
return Collections.unmodifiableMap(remote);
|
||||
return remote;
|
||||
} catch (FormatException e) {
|
||||
throw new DbException(e);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,6 @@ import java.security.SecureRandom;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -443,7 +442,8 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
||||
|
||||
@Override
|
||||
public Collection<SharingInvitationItem> getInvitations() throws DbException {
|
||||
List<SharingInvitationItem> invitations = new ArrayList<SharingInvitationItem>();
|
||||
List<SharingInvitationItem> invitations =
|
||||
new ArrayList<SharingInvitationItem>();
|
||||
Transaction txn = db.startTransaction(true);
|
||||
try {
|
||||
Set<S> shareables = new HashSet<S>();
|
||||
@@ -474,7 +474,7 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
||||
invitations.add(invitation);
|
||||
}
|
||||
db.commitTransaction(txn);
|
||||
return Collections.unmodifiableCollection(invitations);
|
||||
return invitations;
|
||||
} catch (FormatException e) {
|
||||
throw new DbException(e);
|
||||
} finally {
|
||||
@@ -523,7 +523,7 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
||||
} finally {
|
||||
db.endTransaction(txn);
|
||||
}
|
||||
return Collections.unmodifiableList(subscribers);
|
||||
return subscribers;
|
||||
}
|
||||
|
||||
private List<Contact> getSharedBy(Transaction txn, GroupId g)
|
||||
@@ -556,7 +556,7 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
||||
} finally {
|
||||
db.endTransaction(txn);
|
||||
}
|
||||
return Collections.unmodifiableList(shared);
|
||||
return shared;
|
||||
} catch (FormatException e) {
|
||||
throw new DbException(e);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import org.briarproject.util.ByteUtils;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.briarproject.api.sync.PacketTypes.ACK;
|
||||
@@ -74,19 +73,22 @@ class PacketReaderImpl implements PacketReader {
|
||||
state = State.BUFFER_FULL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eof() throws IOException {
|
||||
if (state == State.BUFFER_EMPTY) readPacket();
|
||||
if (state == State.BUFFER_EMPTY) throw new IllegalStateException();
|
||||
return state == State.EOF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAck() throws IOException {
|
||||
return !eof() && header[1] == ACK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ack readAck() throws IOException {
|
||||
if (!hasAck()) throw new FormatException();
|
||||
return new Ack(Collections.unmodifiableList(readMessageIds()));
|
||||
return new Ack(readMessageIds());
|
||||
}
|
||||
|
||||
private List<MessageId> readMessageIds() throws IOException {
|
||||
@@ -102,10 +104,12 @@ class PacketReaderImpl implements PacketReader {
|
||||
return ids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMessage() throws IOException {
|
||||
return !eof() && header[1] == MESSAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message readMessage() throws IOException {
|
||||
if (!hasMessage()) throw new FormatException();
|
||||
if (payloadLength <= MESSAGE_HEADER_LENGTH) throw new FormatException();
|
||||
@@ -125,21 +129,25 @@ class PacketReaderImpl implements PacketReader {
|
||||
return new Message(messageId, groupId, timestamp, raw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOffer() throws IOException {
|
||||
return !eof() && header[1] == OFFER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Offer readOffer() throws IOException {
|
||||
if (!hasOffer()) throw new FormatException();
|
||||
return new Offer(Collections.unmodifiableList(readMessageIds()));
|
||||
return new Offer(readMessageIds());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRequest() throws IOException {
|
||||
return !eof() && header[1] == REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Request readRequest() throws IOException {
|
||||
if (!hasRequest()) throw new FormatException();
|
||||
return new Request(Collections.unmodifiableList(readMessageIds()));
|
||||
return new Request(readMessageIds());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user