1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 17:19:39 +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 431e5b3c67
commit 2f2c2f8663
16 changed files with 92 additions and 99 deletions

View file

@ -113,7 +113,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* and reconnection events.
*/
protected final Set<ConnectionListener> connectionListeners =
new CopyOnWriteArraySet<ConnectionListener>();
new CopyOnWriteArraySet<>();
/**
* A collection of StanzaCollectors which collects packets for a specified filter
@ -142,7 +142,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* List of PacketListeners that will be notified when a new stanza(/packet) was sent.
*/
private final Map<StanzaListener, ListenerWrapper> sendListeners =
new HashMap<StanzaListener, ListenerWrapper>();
new HashMap<>();
/**
* List of PacketListeners that will be notified when a new stanza(/packet) is about to be
@ -150,11 +150,11 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* actually sent to the server.
*/
private final Map<StanzaListener, InterceptorWrapper> interceptors =
new HashMap<StanzaListener, InterceptorWrapper>();
new HashMap<>();
protected final Lock connectionLock = new ReentrantLock();
protected final Map<String, ExtensionElement> streamFeatures = new HashMap<String, ExtensionElement>();
protected final Map<String, ExtensionElement> streamFeatures = new HashMap<>();
/**
* The full JID of the authenticated user, as returned by the resource binding response of the server.
@ -533,7 +533,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
if (!hasFeature(Bind.ELEMENT, Bind.NAMESPACE)) {
// Server never offered resource binding, which is REQURIED in XMPP client and
// Server never offered resource binding, which is REQUIRED in XMPP client and
// server implementations as per RFC6120 7.2
throw new ResourceBindingNotOfferedException();
}
@ -592,7 +592,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
/**
* Get the name of the SASL mechanism that was used to authenticate this connection. This returns the name of
* mechanism which was used the last time this conneciton was authenticated, and will return <code>null</code> if
* mechanism which was used the last time this connection was authenticated, and will return <code>null</code> if
* this connection was not authenticated before.
*
* @return the name of the used SASL mechanism.
@ -621,7 +621,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
hostAddresses.add(hostAddress);
}
else if (config.host != null) {
hostAddresses = new ArrayList<HostAddress>(1);
hostAddresses = new ArrayList<>(1);
HostAddress hostAddress = DNSUtil.getDNSResolver().lookupHostAddress(config.host, config.port, failedAddresses, config.getDnssecMode());
if (hostAddress != null) {
hostAddresses.add(hostAddress);
@ -862,7 +862,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
debugger.onOutgoingStreamElement(packet);
}
final List<StanzaListener> listenersToNotify = new LinkedList<StanzaListener>();
final List<StanzaListener> listenersToNotify = new LinkedList<>();
synchronized (sendListeners) {
for (ListenerWrapper listenerWrapper : sendListeners.values()) {
if (listenerWrapper.filterMatches(packet)) {
@ -918,7 +918,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* @param packet the stanza(/packet) that is going to be sent to the server
*/
private void firePacketInterceptors(Stanza packet) {
List<StanzaListener> interceptorsToInvoke = new LinkedList<StanzaListener>();
List<StanzaListener> interceptorsToInvoke = new LinkedList<>();
synchronized (interceptors) {
for (InterceptorWrapper interceptorWrapper : interceptors.values()) {
if (interceptorWrapper.filterMatches(packet)) {
@ -1029,7 +1029,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
final IQ iq = (IQ) packet;
if (iq.isRequestIQ()) {
final String key = XmppStringUtils.generateKey(iq.getChildElementName(), iq.getChildElementNamespace());
IQRequestHandler iqRequestHandler = null;
IQRequestHandler iqRequestHandler;
final IQ.Type type = iq.getType();
switch (type) {
case set:
@ -1112,7 +1112,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
// First handle the async recv listeners. Note that this code is very similar to what follows a few lines below,
// the only difference is that asyncRecvListeners is used here and that the packet listeners are started in
// their own thread.
final Collection<StanzaListener> listenersToNotify = new LinkedList<StanzaListener>();
final Collection<StanzaListener> listenersToNotify = new LinkedList<>();
synchronized (asyncRecvListeners) {
for (ListenerWrapper listenerWrapper : asyncRecvListeners.values()) {
if (listenerWrapper.filterMatches(packet)) {
@ -1342,7 +1342,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
removeCallbacksService.shutdownNow();
singleThreadedExecutorService.shutdownNow();
} catch (Throwable t) {
LOGGER.log(Level.WARNING, "finalize() threw trhowable", t);
LOGGER.log(Level.WARNING, "finalize() threw throwable", t);
}
finally {
super.finalize();

View file

@ -84,7 +84,7 @@ public abstract class SmackFuture<V, E extends Exception> implements Future<V>,
return this;
}
private final V getOrThrowExecutionException() throws ExecutionException {
private V getOrThrowExecutionException() throws ExecutionException {
assert (result != null || exception != null || cancelled);
if (result != null) {
return result;

View file

@ -78,7 +78,7 @@ public interface XMPPConnection {
*
* @return the XMPP domain of this XMPP session.
*/
public DomainBareJid getXMPPServiceDomain();
DomainBareJid getXMPPServiceDomain();
/**
* Returns the host name of the server where the XMPP server is running. This would be the
@ -86,7 +86,7 @@ public interface XMPPConnection {
*
* @return the host name of the server where the XMPP server is running or null if not yet connected.
*/
public String getHost();
String getHost();
/**
* Returns the port number of the XMPP server for this connection. The default port
@ -94,7 +94,7 @@ public interface XMPPConnection {
*
* @return the port number of the XMPP server or 0 if not yet connected.
*/
public int getPort();
int getPort();
/**
* Returns the full XMPP address of the user that is logged in to the connection or
@ -103,7 +103,7 @@ public interface XMPPConnection {
*
* @return the full XMPP address of the user logged in.
*/
public EntityFullJid getUser();
EntityFullJid getUser();
/**
* Returns the stream ID for this connection, which is the value set by the server
@ -113,35 +113,35 @@ public interface XMPPConnection {
* not connected to the server.
* @see <a href="http://xmpp.org/rfcs/rfc6120.html#streams-attr-id">RFC 6120 § 4.7.3. id</a>
*/
public String getStreamId();
String getStreamId();
/**
* Returns true if currently connected to the XMPP server.
*
* @return true if connected.
*/
public boolean isConnected();
boolean isConnected();
/**
* Returns true if currently authenticated by successfully calling the login method.
*
* @return true if authenticated.
*/
public boolean isAuthenticated();
boolean isAuthenticated();
/**
* Returns true if currently authenticated anonymously.
*
* @return true if authenticated anonymously.
*/
public boolean isAnonymous();
boolean isAnonymous();
/**
* Returns true if the connection to the server has successfully negotiated encryption.
*
* @return true if a secure connection to the server.
*/
public boolean isSecureConnection();
boolean isSecureConnection();
/**
* Returns true if network traffic is being compressed. When using stream compression network
@ -151,7 +151,7 @@ public interface XMPPConnection {
*
* @return true if network traffic is being compressed.
*/
public boolean isUsingCompression();
boolean isUsingCompression();
/**
* Sends the specified stanza to the server.
@ -160,7 +160,7 @@ public interface XMPPConnection {
* @throws NotConnectedException if the connection is not connected.
* @throws InterruptedException
* */
public void sendStanza(Stanza stanza) throws NotConnectedException, InterruptedException;
void sendStanza(Stanza stanza) throws NotConnectedException, InterruptedException;
/**
* Send a Nonza.
@ -174,7 +174,7 @@ public interface XMPPConnection {
* @throws NotConnectedException
* @throws InterruptedException
*/
public void sendNonza(Nonza nonza) throws NotConnectedException, InterruptedException;
void sendNonza(Nonza nonza) throws NotConnectedException, InterruptedException;
/**
* Adds a connection listener to this connection that will be notified when
@ -182,14 +182,14 @@ public interface XMPPConnection {
*
* @param connectionListener a connection listener.
*/
public void addConnectionListener(ConnectionListener connectionListener);
void addConnectionListener(ConnectionListener connectionListener);
/**
* Removes a connection listener from this connection.
*
* @param connectionListener a connection listener.
*/
public void removeConnectionListener(ConnectionListener connectionListener);
void removeConnectionListener(ConnectionListener connectionListener);
/**
* Creates a new stanza(/packet) collector collecting packets that are replies to <code>packet</code>.
@ -202,7 +202,7 @@ public interface XMPPConnection {
* @throws NotConnectedException
* @throws InterruptedException
*/
public StanzaCollector createStanzaCollectorAndSend(IQ packet) throws NotConnectedException, InterruptedException;
StanzaCollector createStanzaCollectorAndSend(IQ packet) throws NotConnectedException, InterruptedException;
/**
* Creates a new stanza(/packet) collector for this connection. A stanza(/packet) filter determines
@ -216,7 +216,7 @@ public interface XMPPConnection {
* @throws InterruptedException
* @throws NotConnectedException
*/
public StanzaCollector createStanzaCollectorAndSend(StanzaFilter packetFilter, Stanza packet)
StanzaCollector createStanzaCollectorAndSend(StanzaFilter packetFilter, Stanza packet)
throws NotConnectedException, InterruptedException;
/**
@ -235,7 +235,7 @@ public interface XMPPConnection {
* @param packetFilter the stanza(/packet) filter to use.
* @return a new stanza(/packet) collector.
*/
public StanzaCollector createStanzaCollector(StanzaFilter packetFilter);
StanzaCollector createStanzaCollector(StanzaFilter packetFilter);
/**
* Create a new stanza(/packet) collector with the given stanza(/packet) collector configuration.
@ -248,14 +248,14 @@ public interface XMPPConnection {
* @return a new stanza(/packet) collector.
* @since 4.1
*/
public StanzaCollector createStanzaCollector(StanzaCollector.Configuration configuration);
StanzaCollector createStanzaCollector(StanzaCollector.Configuration configuration);
/**
* Remove a stanza(/packet) collector of this connection.
*
* @param collector a stanza(/packet) collectors which was created for this connection.
*/
public void removeStanzaCollector(StanzaCollector collector);
void removeStanzaCollector(StanzaCollector collector);
/**
* Registers a <b>synchronous</b> stanza(/packet) listener with this connection. A stanza(/packet) listener will be invoked only when
@ -274,7 +274,7 @@ public interface XMPPConnection {
* @see #addPacketInterceptor(StanzaListener, StanzaFilter)
* @since 4.1
*/
public void addSyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter);
void addSyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter);
/**
* Removes a stanza(/packet) listener for received packets from this connection.
@ -283,7 +283,7 @@ public interface XMPPConnection {
* @return true if the stanza(/packet) listener was removed
* @since 4.1
*/
public boolean removeSyncStanzaListener(StanzaListener packetListener);
boolean removeSyncStanzaListener(StanzaListener packetListener);
/**
* Registers an <b>asynchronous</b> stanza(/packet) listener with this connection. A stanza(/packet) listener will be invoked only
@ -300,7 +300,7 @@ public interface XMPPConnection {
* @see #addPacketInterceptor(StanzaListener, StanzaFilter)
* @since 4.1
*/
public void addAsyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter);
void addAsyncStanzaListener(StanzaListener packetListener, StanzaFilter packetFilter);
/**
* Removes an <b>asynchronous</b> stanza(/packet) listener for received packets from this connection.
@ -309,7 +309,7 @@ public interface XMPPConnection {
* @return true if the stanza(/packet) listener was removed
* @since 4.1
*/
public boolean removeAsyncStanzaListener(StanzaListener packetListener);
boolean removeAsyncStanzaListener(StanzaListener packetListener);
/**
* Registers a stanza(/packet) listener with this connection. The listener will be
@ -322,14 +322,14 @@ public interface XMPPConnection {
* @param packetListener the stanza(/packet) listener to notify of sent packets.
* @param packetFilter the stanza(/packet) filter to use.
*/
public void addPacketSendingListener(StanzaListener packetListener, StanzaFilter packetFilter);
void addPacketSendingListener(StanzaListener packetListener, StanzaFilter packetFilter);
/**
* Removes a stanza(/packet) listener for sending packets from this connection.
*
* @param packetListener the stanza(/packet) listener to remove.
*/
public void removePacketSendingListener(StanzaListener packetListener);
void removePacketSendingListener(StanzaListener packetListener);
/**
* Registers a stanza(/packet) interceptor with this connection. The interceptor will be
@ -343,14 +343,14 @@ public interface XMPPConnection {
* @param packetInterceptor the stanza(/packet) interceptor to notify of packets about to be sent.
* @param packetFilter the stanza(/packet) filter to use.
*/
public void addPacketInterceptor(StanzaListener packetInterceptor, StanzaFilter packetFilter);
void addPacketInterceptor(StanzaListener packetInterceptor, StanzaFilter packetFilter);
/**
* Removes a stanza(/packet) interceptor.
*
* @param packetInterceptor the stanza(/packet) interceptor to remove.
*/
public void removePacketInterceptor(StanzaListener packetInterceptor);
void removePacketInterceptor(StanzaListener packetInterceptor);
/**
* Returns the current value of the reply timeout in milliseconds for request for this
@ -358,7 +358,7 @@ public interface XMPPConnection {
*
* @return the reply timeout in milliseconds
*/
public long getReplyTimeout();
long getReplyTimeout();
/**
* Set the stanza(/packet) reply timeout in milliseconds. In most cases, Smack will throw a
@ -366,7 +366,7 @@ public interface XMPPConnection {
*
* @param timeout for a reply in milliseconds
*/
public void setReplyTimeout(long timeout);
void setReplyTimeout(long timeout);
/**
* Get the connection counter of this XMPPConnection instance. Those can be used as ID to
@ -375,9 +375,9 @@ public interface XMPPConnection {
*
* @return the connection counter of this XMPPConnection
*/
public int getConnectionCounter();
int getConnectionCounter();
public static enum FromMode {
enum FromMode {
/**
* Leave the 'from' attribute unchanged. This is the behavior of Smack < 4.0
*/
@ -400,14 +400,14 @@ public interface XMPPConnection {
*
* @param fromMode
*/
public void setFromMode(FromMode fromMode);
void setFromMode(FromMode fromMode);
/**
* Get the currently active FromMode.
*
* @return the currently active {@link FromMode}
*/
public FromMode getFromMode();
FromMode getFromMode();
/**
* Get the feature stanza(/packet) extensions for a given stream feature of the
@ -417,7 +417,7 @@ public interface XMPPConnection {
* @param namespace
* @return a stanza(/packet) extensions of the feature or <code>null</code>
*/
public <F extends ExtensionElement> F getFeature(String element, String namespace);
<F extends ExtensionElement> F getFeature(String element, String namespace);
/**
* Return true if the server supports the given stream feature.
@ -426,7 +426,7 @@ public interface XMPPConnection {
* @param namespace
* @return true if the server supports the stream feature.
*/
public boolean hasFeature(String element, String namespace);
boolean hasFeature(String element, String namespace);
/**
* Send an IQ request asynchronously. The connection's default reply timeout will be used.
@ -434,7 +434,7 @@ public interface XMPPConnection {
* @param request the IQ request to send.
* @return a SmackFuture for the response.
*/
public SmackFuture<IQ, Exception> sendIqRequestAsync(IQ request);
SmackFuture<IQ, Exception> sendIqRequestAsync(IQ request);
/**
* Send an IQ request asynchronously.
@ -443,7 +443,7 @@ public interface XMPPConnection {
* @param timeout the reply timeout in milliseconds.
* @return a SmackFuture for the response.
*/
public SmackFuture<IQ, Exception> sendIqRequestAsync(IQ request, long timeout);
SmackFuture<IQ, Exception> sendIqRequestAsync(IQ request, long timeout);
/**
* Send a stanza asynchronously, waiting for exactly one response stanza using the given reply filter. The
@ -453,7 +453,7 @@ public interface XMPPConnection {
* @param replyFilter the filter used for the response stanza.
* @return a SmackFuture for the response.
*/
public <S extends Stanza> SmackFuture<S, Exception> sendAsync(S stanza, StanzaFilter replyFilter);
<S extends Stanza> SmackFuture<S, Exception> sendAsync(S stanza, StanzaFilter replyFilter);
/**
* Send a stanza asynchronously, waiting for exactly one response stanza using the given reply filter.
@ -463,7 +463,7 @@ public interface XMPPConnection {
* @param timeout the reply timeout in milliseconds.
* @return a SmackFuture for the response.
*/
public <S extends Stanza> SmackFuture<S, Exception> sendAsync(S stanza, StanzaFilter replyFilter, long timeout);
<S extends Stanza> SmackFuture<S, Exception> sendAsync(S stanza, StanzaFilter replyFilter, long timeout);
/**
* Send a stanza and wait asynchronously for a response by using <code>replyFilter</code>.
@ -482,7 +482,7 @@ public interface XMPPConnection {
*/
@Deprecated
// TODO: Remove in Smack 4.4.
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
StanzaListener callback) throws NotConnectedException, InterruptedException;
/**
@ -503,7 +503,7 @@ public interface XMPPConnection {
*/
@Deprecated
// TODO: Remove in Smack 4.4.
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, StanzaListener callback,
void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, StanzaListener callback,
@SuppressWarnings("deprecation") ExceptionCallback exceptionCallback) throws NotConnectedException, InterruptedException;
/**
@ -525,7 +525,7 @@ public interface XMPPConnection {
*/
@Deprecated
// TODO: Remove in Smack 4.4.
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
final StanzaListener callback, @SuppressWarnings("deprecation") final ExceptionCallback exceptionCallback,
long timeout) throws NotConnectedException, InterruptedException;
@ -542,7 +542,7 @@ public interface XMPPConnection {
*/
@Deprecated
// TODO: Remove in Smack 4.4.
public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback) throws NotConnectedException, InterruptedException;
void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback) throws NotConnectedException, InterruptedException;
/**
* Send a IQ stanza and invoke <code>callback</code> if there is a result of
@ -561,7 +561,7 @@ public interface XMPPConnection {
*/
@Deprecated
// TODO: Remove in Smack 4.4.
public void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback,
void sendIqWithResponseCallback(IQ iqRequest, StanzaListener callback,
@SuppressWarnings("deprecation") ExceptionCallback exceptionCallback) throws NotConnectedException, InterruptedException;
/**
@ -582,7 +582,7 @@ public interface XMPPConnection {
*/
@Deprecated
// TODO: Remove in Smack 4.4.
public void sendIqWithResponseCallback(IQ iqRequest, final StanzaListener callback,
void sendIqWithResponseCallback(IQ iqRequest, final StanzaListener callback,
@SuppressWarnings("deprecation") final ExceptionCallback exceptionCallback, long timeout)
throws NotConnectedException, InterruptedException;
@ -593,7 +593,7 @@ public interface XMPPConnection {
* @param callback the callback invoked once the stanza(/packet) filter matches a stanza.
* @param packetFilter the filter to match stanzas or null to match all.
*/
public void addOneTimeSyncCallback(StanzaListener callback, StanzaFilter packetFilter);
void addOneTimeSyncCallback(StanzaListener callback, StanzaFilter packetFilter);
/**
* Register an IQ request handler with this connection.
@ -603,7 +603,7 @@ public interface XMPPConnection {
* @param iqRequestHandler the IQ request handler to register.
* @return the previously registered IQ request handler or null.
*/
public IQRequestHandler registerIQRequestHandler(IQRequestHandler iqRequestHandler);
IQRequestHandler registerIQRequestHandler(IQRequestHandler iqRequestHandler);
/**
* Convenience method for {@link #unregisterIQRequestHandler(String, String, org.jivesoftware.smack.packet.IQ.Type)}.
@ -611,7 +611,7 @@ public interface XMPPConnection {
* @param iqRequestHandler
* @return the previously registered IQ request handler or null.
*/
public IQRequestHandler unregisterIQRequestHandler(IQRequestHandler iqRequestHandler);
IQRequestHandler unregisterIQRequestHandler(IQRequestHandler iqRequestHandler);
/**
* Unregister an IQ request handler with this connection.
@ -621,13 +621,13 @@ public interface XMPPConnection {
* @param type the IQ type the IQ request handler is responsible for.
* @return the previously registered IQ request handler or null.
*/
public IQRequestHandler unregisterIQRequestHandler(String element, String namespace, IQ.Type type);
IQRequestHandler unregisterIQRequestHandler(String element, String namespace, IQ.Type type);
/**
* Returns the timestamp in milliseconds when the last stanza was received.
*
* @return the timestamp in milliseconds
*/
public long getLastStanzaReceived();
long getLastStanzaReceived();
}

View file

@ -18,6 +18,6 @@ package org.jivesoftware.smack.util;
public interface ExceptionCallback<E> {
public void processException(E exception);
void processException(E exception);
}