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

Fix minor codestyle issues

This commit is contained in:
Paul Schaub 2017-12-13 23:10:11 +01:00 committed by Florian Schmaus
parent 200f90ffdc
commit cb18056613
422 changed files with 1404 additions and 1444 deletions

View file

@ -42,10 +42,10 @@ import org.jxmpp.jid.EntityJid;
@Deprecated
public class Chat {
private ChatManager chatManager;
private String threadID;
private EntityJid participant;
private final Set<ChatMessageListener> listeners = new CopyOnWriteArraySet<ChatMessageListener>();
private final ChatManager chatManager;
private final String threadID;
private final EntityJid participant;
private final Set<ChatMessageListener> listeners = new CopyOnWriteArraySet<>();
/**
* Creates a new chat with the specified user and thread ID.

View file

@ -60,7 +60,7 @@ public final class ChatManager extends Manager{
private static final Logger LOGGER = Logger.getLogger(ChatManager.class.getName());
private static final Map<XMPPConnection, ChatManager> INSTANCES = new WeakHashMap<XMPPConnection, ChatManager>();
private static final Map<XMPPConnection, ChatManager> INSTANCES = new WeakHashMap<>();
/**
* Sets the default behaviour for allowing 'normal' messages to be used in chats. As some clients don't set
@ -128,23 +128,21 @@ public final class ChatManager extends Manager{
/**
* Maps thread ID to chat.
*/
private Map<String, Chat> threadChats = new ConcurrentHashMap<>();
private final Map<String, Chat> threadChats = new ConcurrentHashMap<>();
/**
* Maps jids to chats
*/
private Map<Jid, Chat> jidChats = new ConcurrentHashMap<>();
private final Map<Jid, Chat> jidChats = new ConcurrentHashMap<>();
/**
* Maps base jids to chats
*/
private Map<EntityBareJid, Chat> baseJidChats = new ConcurrentHashMap<>();
private final Map<EntityBareJid, Chat> baseJidChats = new ConcurrentHashMap<>();
private Set<ChatManagerListener> chatManagerListeners
= new CopyOnWriteArraySet<ChatManagerListener>();
private final Set<ChatManagerListener> chatManagerListeners = new CopyOnWriteArraySet<>();
private Map<MessageListener, StanzaFilter> interceptors
= new WeakHashMap<MessageListener, StanzaFilter>();
private final Map<MessageListener, StanzaFilter> interceptors = new WeakHashMap<>();
private ChatManager(XMPPConnection connection) {
super(connection);
@ -339,7 +337,7 @@ public final class ChatManager extends Manager{
}
/**
* Register a new listener with the ChatManager to recieve events related to chats.
* Register a new listener with the ChatManager to receive events related to chats.
*
* @param listener the listener.
*/

View file

@ -24,13 +24,13 @@ import org.jxmpp.jid.Jid;
public interface PresenceEventListener {
public void presenceAvailable(FullJid address, Presence availablePresence);
void presenceAvailable(FullJid address, Presence availablePresence);
public void presenceUnavailable(FullJid address, Presence presence);
void presenceUnavailable(FullJid address, Presence presence);
public void presenceError(Jid address, Presence errorPresence);
void presenceError(Jid address, Presence errorPresence);
public void presenceSubscribed(BareJid address, Presence subscribedPresence);
void presenceSubscribed(BareJid address, Presence subscribedPresence);
public void presenceUnsubscribed(BareJid address, Presence unsubscribedPresence);
void presenceUnsubscribed(BareJid address, Presence unsubscribedPresence);
}

View file

@ -147,7 +147,7 @@ public final class Roster extends Manager {
private static int defaultNonRosterPresenceMapMaxSize = INITIAL_DEFAULT_NON_ROSTER_PRESENCE_MAP_SIZE;
private RosterStore rosterStore;
private final Map<String, RosterGroup> groups = new ConcurrentHashMap<String, RosterGroup>();
private final Map<String, RosterGroup> groups = new ConcurrentHashMap<>();
/**
* Concurrent hash map from JID to its roster entry.
@ -754,7 +754,7 @@ public final class Roster extends Manager {
final XMPPConnection connection = getAuthenticatedConnectionOrThrow();
// Only remove the entry if it's in the entry list.
// The actual removal logic takes place in RosterPacketListenerprocess>>Packet(Packet)
// The actual removal logic takes place in RosterPacketListenerProcess>>Packet(Packet)
if (!entries.containsKey(entry.getJid())) {
return;
}
@ -781,7 +781,7 @@ public final class Roster extends Manager {
* <p>
* The method guarantees that the listener is only invoked after
* {@link RosterEntries#rosterEntries(Collection)} has been invoked, and that all roster events
* that happen while <code>rosterEntires(Collection) </code> is called are queued until the
* that happen while <code>rosterEntries(Collection) </code> is called are queued until the
* method returns.
* </p>
* <p>
@ -1078,7 +1078,7 @@ public final class Roster extends Manager {
res = Arrays.asList(presence);
}
else {
List<Presence> answer = new ArrayList<Presence>();
List<Presence> answer = new ArrayList<>();
// Used in case no available presence is found
Presence unavailable = null;
for (Presence presence : userPresences.values()) {
@ -1213,7 +1213,7 @@ public final class Roster extends Manager {
}
catch (NotConnectedException e) {
throw new IllegalStateException(
"presencePakcetListener should never throw a NotConnectedException when processStanza is called with a presence of type unavailable",
"presencePacketListener should never throw a NotConnectedException when processStanza is called with a presence of type unavailable",
e);
}
catch (InterruptedException e) {
@ -1305,7 +1305,7 @@ public final class Roster extends Manager {
}
// Add the entry/user to the groups
List<String> newGroupNames = new ArrayList<String>();
List<String> newGroupNames = new ArrayList<>();
for (String groupName : item.getGroupNames()) {
// Add the group name to the list.
newGroupNames.add(groupName);
@ -1321,7 +1321,7 @@ public final class Roster extends Manager {
}
// Remove user from the remaining groups.
List<String> oldGroupNames = new ArrayList<String>();
List<String> oldGroupNames = new ArrayList<>();
for (RosterGroup group : getGroups()) {
oldGroupNames.add(group.getName());
}
@ -1595,7 +1595,7 @@ public final class Roster extends Manager {
RosterPacket rosterPacket = (RosterPacket) packet;
// Ignore items without valid subscription type
ArrayList<Item> validItems = new ArrayList<RosterPacket.Item>();
ArrayList<Item> validItems = new ArrayList<>();
for (RosterPacket.Item item : rosterPacket.getRosterItems()) {
if (hasValidSubscriptionType(item)) {
validItems.add(item);
@ -1659,10 +1659,10 @@ public final class Roster extends Manager {
fireRosterChangedEvent(addedEntries, updatedEntries, deletedEntries);
// Call the roster loaded listeners after the roster events have been fired. This is
// imporant because the user may call getEntriesAndAddListener() in onRosterLoaded(),
// important because the user may call getEntriesAndAddListener() in onRosterLoaded(),
// and if the order would be the other way around, the roster listener added by
// getEntriesAndAddListener() would be invoked with information that was already
// available at the time getEntriesAndAddListenr() was called.
// available at the time getEntriesAndAddListener() was called.
try {
synchronized (rosterLoadedListeners) {
for (RosterLoadedListener rosterLoadedListener : rosterLoadedListeners) {
@ -1721,7 +1721,7 @@ public final class Roster extends Manager {
// A roster push must contain exactly one entry
Collection<Item> items = rosterPacket.getRosterItems();
if (items.size() != 1) {
LOGGER.warning("Ignoring roster push with not exaclty one entry. size=" + items.size());
LOGGER.warning("Ignoring roster push with not exactly one entry. size=" + items.size());
return IQ.createErrorResponse(iqRequest, Condition.bad_request);
}
@ -1730,7 +1730,7 @@ public final class Roster extends Manager {
Collection<Jid> deletedEntries = new ArrayList<>();
Collection<Jid> unchangedEntries = new ArrayList<>();
// We assured above that the size of items is exaclty 1, therefore we are able to
// We assured above that the size of items is exactly 1, therefore we are able to
// safely retrieve this single item here.
Item item = items.iterator().next();
RosterEntry entry = new RosterEntry(item, Roster.this, connection);

View file

@ -20,6 +20,6 @@ import java.util.Collection;
public interface RosterEntries {
public void rosterEntries(Collection<RosterEntry> rosterEntries);
void rosterEntries(Collection<RosterEntry> rosterEntries);
}

View file

@ -117,11 +117,9 @@ public final class RosterEntry extends Manager {
}
/**
* Updates the state of the entry with the new values.
* Updates this entries item.
*
* @param name the nickname for the entry.
* @param type the subscription type.
* @param subscriptionPending TODO
* @param item new item
*/
void updateItem(RosterPacket.Item item) {
assert (item != null);
@ -143,7 +141,7 @@ public final class RosterEntry extends Manager {
* @return an iterator for the groups this entry belongs to.
*/
public List<RosterGroup> getGroups() {
List<RosterGroup> results = new ArrayList<RosterGroup>();
List<RosterGroup> results = new ArrayList<>();
// Loop through all roster groups and find the ones that contain this
// entry. This algorithm should be fine
for (RosterGroup group : roster.getGroups()) {

View file

@ -52,7 +52,7 @@ public class RosterGroup extends Manager {
RosterGroup(String name, XMPPConnection connection) {
super(connection);
this.name = name;
entries = new LinkedHashSet<RosterEntry>();
entries = new LinkedHashSet<>();
}
/**
@ -108,7 +108,7 @@ public class RosterGroup extends Manager {
*/
public List<RosterEntry> getEntries() {
synchronized (entries) {
return new ArrayList<RosterEntry>(entries);
return new ArrayList<>(entries);
}
}
@ -200,7 +200,7 @@ public class RosterGroup extends Manager {
*/
public void removeEntry(RosterEntry entry) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// Only remove the entry if it's in the entry list.
// Remove the entry locally, if we wait for RosterPacketListenerprocess>>Packet(Packet)
// Remove the entry locally, if we wait for RosterPacketListenerProcess>>Packet(Packet)
// to take place the entry will exist in the group until a packet is received from the
// server.
synchronized (entries) {

View file

@ -37,21 +37,21 @@ public interface RosterListener {
*
* @param addresses the XMPP addresses of the contacts that have been added to the roster.
*/
public void entriesAdded(Collection<Jid> addresses);
void entriesAdded(Collection<Jid> addresses);
/**
* Called when a roster entries are updated.
*
* @param addresses the XMPP addresses of the contacts whose entries have been updated.
*/
public void entriesUpdated(Collection<Jid> addresses);
void entriesUpdated(Collection<Jid> addresses);
/**
* Called when a roster entries are removed.
*
* @param addresses the XMPP addresses of the contacts that have been removed from the roster.
*/
public void entriesDeleted(Collection<Jid> addresses);
void entriesDeleted(Collection<Jid> addresses);
/**
* Called when the presence of a roster entry is changed. Care should be taken
@ -78,5 +78,5 @@ public interface RosterListener {
* @param presence the presence that changed.
* @see Roster#getPresence(org.jxmpp.jid.BareJid)
*/
public void presenceChanged(Presence presence);
void presenceChanged(Presence presence);
}

View file

@ -33,7 +33,7 @@ public interface RosterLoadedListener {
*
* @param roster the Roster that was loaded successfully.
*/
public void onRosterLoaded(Roster roster);
void onRosterLoaded(Roster roster);
/**
* Called when roster loading has failed.
@ -46,6 +46,6 @@ public interface RosterLoadedListener {
* @param exception the exception which caused the failure.
* @since 4.2
*/
public void onRosterLoadingFailed(Exception exception);
void onRosterLoadingFailed(Exception exception);
}

View file

@ -31,7 +31,7 @@ import org.jxmpp.jid.Jid;
*/
public interface SubscribeListener {
public enum SubscribeAnswer {
enum SubscribeAnswer {
/**
* Approve the subscription request.
*/
@ -56,6 +56,6 @@ public interface SubscribeListener {
* @param subscribeRequest the presence stanza used for the request.
* @return a answer to the request, or <code>null</code>
*/
public SubscribeAnswer processSubscribe(Jid from, Presence subscribeRequest);
SubscribeAnswer processSubscribe(Jid from, Presence subscribeRequest);
}

View file

@ -44,7 +44,7 @@ public class RosterPacket extends IQ {
public static final String ELEMENT = QUERY_ELEMENT;
public static final String NAMESPACE = "jabber:iq:roster";
private final List<Item> rosterItems = new ArrayList<Item>();
private final List<Item> rosterItems = new ArrayList<>();
private String rosterVersion;
public RosterPacket() {
@ -80,7 +80,7 @@ public class RosterPacket extends IQ {
*/
public List<Item> getRosterItems() {
synchronized (rosterItems) {
return new ArrayList<Item>(rosterItems);
return new ArrayList<>(rosterItems);
}
}
@ -153,7 +153,7 @@ public class RosterPacket extends IQ {
this.jid = Objects.requireNonNull(jid);
this.name = name;
this.subscriptionPending = subscriptionPending;
groupNames = new CopyOnWriteArraySet<String>();
groupNames = new CopyOnWriteArraySet<>();
}
@Override
@ -341,7 +341,7 @@ public class RosterPacket extends IQ {
}
public static enum ItemType {
public enum ItemType {
/**
* The user does not have a subscription to the contact's presence, and the contact does not
@ -379,7 +379,7 @@ public class RosterPacket extends IQ {
private final String symbol;
private ItemType(char secondSymbolChar) {
ItemType(char secondSymbolChar) {
StringBuilder sb = new StringBuilder(2);
sb.append(ME).append(secondSymbolChar);
symbol = sb.toString();

View file

@ -29,7 +29,6 @@ import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.roster.packet.RosterPacket;
import org.jivesoftware.smack.roster.packet.RosterPacket.Item;
import org.jivesoftware.smack.roster.provider.RosterPacketProvider;
import org.jivesoftware.smack.util.FileUtils;
@ -121,7 +120,7 @@ public final class DirectoryRosterStore implements RosterStore {
@Override
public List<Item> getEntries() {
List<Item> entries = new ArrayList<RosterPacket.Item>();
List<Item> entries = new ArrayList<>();
for (File file : fileDir.listFiles(rosterDirFilter)) {
Item entry = readEntry(file);

View file

@ -35,46 +35,46 @@ public interface RosterStore {
*
* @return List of {@link org.jivesoftware.smack.roster.RosterEntry} or <code>null</code>.
*/
public List<RosterPacket.Item> getEntries();
List<RosterPacket.Item> getEntries();
/**
* This method returns the roster item in this store for the given JID.
* @param bareJid The bare JID of the RosterEntry
* @return The {@link org.jivesoftware.smack.roster.RosterEntry} which belongs to that user
*/
public RosterPacket.Item getEntry(Jid bareJid);
RosterPacket.Item getEntry(Jid bareJid);
/**
* This method returns the version number as specified by the "ver" attribute
* of the local store. For a fresh store, this MUST be the empty string.
* @return local roster version
*/
public String getRosterVersion();
String getRosterVersion();
/**
* This method stores a new roster entry in this store or updates an existing one.
* @param item the entry to store
* @param version the new roster version
* @return True if successful
*/
public boolean addEntry(RosterPacket.Item item, String version);
boolean addEntry(RosterPacket.Item item, String version);
/**
* This method updates the store so that it contains only the given entries.
* @param items the entries to store
* @param version the new roster version
* @return True if successful
*/
public boolean resetEntries(Collection<RosterPacket.Item> items, String version);
boolean resetEntries(Collection<RosterPacket.Item> items, String version);
/**
* Removes an entry from the store.
* @param bareJid The bare JID of the entry to be removed
* @param version the new roster version
* @return True if successful
*/
public boolean removeEntry(Jid bareJid, String version);
boolean removeEntry(Jid bareJid, String version);
/**
* Reset the store by removing all entries and setting the version to the empty String.
*
* @since 4.2
*/
public void resetStore();
void resetStore();
}

View file

@ -374,12 +374,12 @@ public class ChatConnectionTest {
}
private static class TestChatServer extends Thread {
private Stanza chatPacket;
private DummyConnection con;
private final Stanza chatPacket;
private final DummyConnection con;
TestChatServer(Stanza chatMsg, DummyConnection conect) {
TestChatServer(Stanza chatMsg, DummyConnection connection) {
chatPacket = chatMsg;
con = conect;
con = connection;
}
@Override

View file

@ -32,9 +32,9 @@ import org.junit.Test;
*/
public class RosterOfflineTest {
DummyConnection connection;
private DummyConnection connection;
Roster roster;
private Roster roster;
@Before
public void setup() {

View file

@ -387,7 +387,7 @@ public class RosterTest extends InitSmackIm {
connection.processStanza(packet);
// Smack should reply with an error IQ
ErrorIQ errorIQ = (ErrorIQ) connection.getSentPacket();
ErrorIQ errorIQ = connection.getSentPacket();
assertEquals(requestId, errorIQ.getStanzaId());
assertEquals(Condition.service_unavailable, errorIQ.getError().getCondition());
@ -537,9 +537,7 @@ public class RosterTest extends InitSmackIm {
* Initialize the roster according to the example in
* <a href="http://xmpp.org/rfcs/rfc3921.html#roster-login"
* >RFC3921: Retrieving One's Roster on Login</a>.
*
* @param connection the dummy connection of which the provided roster belongs to.
* @param roster the roster (or buddy list) which should be initialized.
*
* @throws SmackException
* @throws XmppStringprepException
*/

View file

@ -108,13 +108,13 @@ public class RosterVersioningTest {
Collection<RosterEntry> entries = roster.getEntries();
assertSame("Size of the roster", 3, entries.size());
HashSet<Item> items = new HashSet<Item>();
HashSet<Item> items = new HashSet<>();
for (RosterEntry entry : entries) {
items.add(RosterEntry.toRosterItem(entry));
}
RosterStore store = DirectoryRosterStore.init(tmpFolder.newFolder());
populateStore(store);
assertEquals("Elements of the roster", new HashSet<Item>(store.getEntries()), items);
assertEquals("Elements of the roster", new HashSet<>(store.getEntries()), items);
for (RosterEntry entry : entries) {
assertTrue("joe stevens".equals(entry.getName()) || "geoff hurley".equals(entry.getName())
@ -168,7 +168,7 @@ public class RosterVersioningTest {
RosterStore store = roster.getRosterStore();
assertEquals("Size of store", 1, store.getEntries().size());
Item item = store.getEntry(vaglafItem.getJid());
assertNotNull("Store contains vaglaf entry");
assertNotNull("Store contains vaglaf entry", item);
assertEquals("vaglaf entry in store equals the sent entry", vaglafItem, item);
}
@ -201,11 +201,11 @@ public class RosterVersioningTest {
assertNotNull("Expect vaglaf to be added", storedItem);
assertEquals("Expect vaglaf to be equal to pushed item", pushedItem, storedItem);
Collection<Item> rosterItems = new HashSet<Item>();
Collection<Item> rosterItems = new HashSet<>();
for (RosterEntry entry : roster.getEntries()) {
rosterItems.add(RosterEntry.toRosterItem(entry));
}
assertEquals(rosterItems, new HashSet<Item>(store.getEntries()));
assertEquals(rosterItems, new HashSet<>(store.getEntries()));
}
// Simulate a roster push removing vaglaf

View file

@ -150,7 +150,7 @@ public class SubscriptionPreApprovalTest extends InitSmackIm {
*/
abstract void verifyRosterUpdateRequest(final RosterPacket updateRequest);
/**
* Overwrite this method to check if recieved pre-approval request is valid
* Overwrite this method to check if received pre-approval request is valid
*
* @param preApproval the request which would be sent to server.
*/