1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-24 21:12:05 +01:00

Enable MissingJavadocPackage and UnnecessaryParentheses checkstyle checks

This commit is contained in:
Florian Schmaus 2019-07-24 09:18:39 +02:00
parent 2ac452fe1e
commit 4ca2c7cc69
76 changed files with 120 additions and 131 deletions

View file

@ -212,5 +212,9 @@
<property name="sortImportsInGroupAlphabetically" value="true"/>
<property name="separateLineBetweenGroups" value="true"/>
</module>
<module name="MissingJavadocPackage"/>
<module name="UnnecessaryParentheses"/>
<module name="UnnecessarySemicolonInEnumeration"/>
<module name="UnnecessarySemicolonInTryWithResources"/>
</module>
</module>

View file

@ -65,11 +65,11 @@ public final class BOSHConfiguration extends ConnectionConfiguration {
}
public String getProxyAddress() {
return (proxy != null ? proxy.getProxyAddress() : null);
return proxy != null ? proxy.getProxyAddress() : null;
}
public int getProxyPort() {
return (proxy != null ? proxy.getProxyPort() : 8080);
return proxy != null ? proxy.getProxyPort() : 8080;
}
public boolean isUsingHTTPS() {

View file

@ -755,7 +755,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
hostAddresses = DNSUtil.resolveXMPPServiceDomain(dnsName, failedAddresses, config.getDnssecMode());
}
// Either the populated host addresses are not empty *or* there must be at least one failed address.
assert (!hostAddresses.isEmpty() || !failedAddresses.isEmpty());
assert !hostAddresses.isEmpty() || !failedAddresses.isEmpty();
return failedAddresses;
}
@ -788,7 +788,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
@Override
public final void sendStanza(Stanza stanza) throws NotConnectedException, InterruptedException {
Objects.requireNonNull(stanza, "Stanza must not be null");
assert (stanza instanceof Message || stanza instanceof Presence || stanza instanceof IQ);
assert stanza instanceof Message || stanza instanceof Presence || stanza instanceof IQ;
throwNotConnectedExceptionIfAppropriate();
switch (fromMode) {
@ -1275,7 +1275,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
* @throws InterruptedException
*/
protected void processStanza(final Stanza stanza) throws InterruptedException {
assert (stanza != null);
assert stanza != null;
final SmackDebugger debugger = this.debugger;
if (debugger != null) {
@ -1892,7 +1892,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
@Override
public final String toString() {
EntityFullJid localEndpoint = getUser();
String localEndpointString = (localEndpoint == null ? "not-authenticated" : localEndpoint.toString());
String localEndpointString = localEndpoint == null ? "not-authenticated" : localEndpoint.toString();
return getClass().getSimpleName() + '[' + localEndpointString + "] (" + getConnectionCounter() + ')';
}

View file

@ -209,7 +209,7 @@ public abstract class ConnectionConfiguration {
compressionEnabled = builder.compressionEnabled;
// If the enabledSaslmechanisms are set, then they must not be empty
assert (enabledSaslMechanisms != null ? !enabledSaslMechanisms.isEmpty() : true);
assert enabledSaslMechanisms == null || !enabledSaslMechanisms.isEmpty();
if (dnssecMode != DnssecMode.disabled && customSSLContext != null) {
throw new IllegalStateException("You can not use a custom SSL context with DNSSEC enabled");

View file

@ -447,6 +447,5 @@ public final class ReconnectionManager {
* Policy using fixed amount of time between reconnection attempts.
*/
FIXED_DELAY,
;
}
}

View file

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

View file

@ -172,7 +172,7 @@ public class SmackReactor {
LOGGER.info(this + " shut down after " + shutDownDelay + "ms");
} else {
boolean contained = reactorThreads.remove(this);
assert (contained);
assert contained;
}
}
}

View file

@ -79,7 +79,7 @@ public class SynchronizationPoint<E extends Exception> {
*/
public Exception sendAndWaitForResponse(TopLevelStreamElement request) throws NoResponseException,
NotConnectedException, InterruptedException {
assert (state == State.Initial);
assert state == State.Initial;
connectionLock.lock();
try {
if (request != null) {

View file

@ -56,7 +56,7 @@ public class Java7ZlibInputOutputStream extends XMPPInputOutputStream {
} catch (NoSuchMethodException e) {
}
method = m;
supported = (method != null);
supported = method != null;
}
public Java7ZlibInputOutputStream() {

View file

@ -95,7 +95,7 @@ public final class ZlibXmppCompressionFactory extends XmppCompressionFactory {
}
// There is an invariant of Deflater/Inflater that input should only be set if needsInput() return true.
assert (compressor.needsInput());
assert compressor.needsInput();
final byte[] compressorInputBuffer;
final int compressorInputBufferOffset, compressorInputBufferLength;

View file

@ -86,12 +86,12 @@ public abstract class SmackDebugger {
*/
public final Reader newConnectionReader(Reader reader) {
XmlPrettyPrinter xmlPrettyPrinter = XmlPrettyPrinter.builder()
.setPrettyWriter((sb) -> incomingStreamSink(sb))
.setPrettyWriter(sb -> incomingStreamSink(sb))
.build();
incomingStreamSplitterForPrettyPrinting = new XmppXmlSplitter(xmlPrettyPrinter);
ObservableReader observableReader = new ObservableReader(reader);
observableReader.addReaderListener((readString) -> {
observableReader.addReaderListener(readString -> {
try {
incomingStreamSplitterForPrettyPrinting.append(readString);
}
@ -113,12 +113,12 @@ public abstract class SmackDebugger {
*/
public final Writer newConnectionWriter(Writer writer) {
XmlPrettyPrinter xmlPrettyPrinter = XmlPrettyPrinter.builder()
.setPrettyWriter((sb) -> outgoingStreamSink(sb))
.setPrettyWriter(sb -> outgoingStreamSink(sb))
.build();
outgoingStreamSplitterForPrettyPrinting = new XmppXmlSplitter(xmlPrettyPrinter);
ObservableWriter observableWriter = new ObservableWriter(writer);
observableWriter.addWriterListener((writtenString) -> {
observableWriter.addWriterListener(writtenString -> {
try {
outgoingStreamSplitterForPrettyPrinting.append(writtenString);
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2017-2018 Florian Schmaus.
* Copyright 2017-2019 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -28,7 +28,6 @@ public abstract class AbstractJidTypeFilter implements StanzaFilter {
domainFull,
domainBare,
any,
;
}
protected final JidType jidType;

View file

@ -178,7 +178,7 @@ public abstract class AbstractXmppStateMachineConnection extends AbstractXMPPCon
if (initialStateDescriptor.getClass() == walkStateGraphContext.finalStateClass) {
// If this is used as final state, then it should be marked as such.
assert (initialStateDescriptor.isFinalState());
assert initialStateDescriptor.isFinalState();
// We reached the final state.
invokeConnectionStateMachineListener(new ConnectionStateEvent.FinalStateReached(initialState));
@ -578,7 +578,7 @@ public abstract class AbstractXmppStateMachineConnection extends AbstractXMPPCon
@Override
protected TransitionIntoResult transitionInto(WalkStateGraphContext walkStateGraphContext) {
assert (walkFromDisconnectToAuthenticated == null);
assert walkFromDisconnectToAuthenticated == null;
if (getStateDescriptor().getClass() == walkStateGraphContext.finalStateClass) {
// If this is the final state, then record the walk so far.
walkFromDisconnectToAuthenticated = new ArrayList<>(walkStateGraphContext.walkedStateGraphPath);
@ -780,7 +780,7 @@ public abstract class AbstractXmppStateMachineConnection extends AbstractXMPPCon
if (walkFromDisconnectToAuthenticated != null) {
// If there was already a previous walk to ConnectedButUnauthenticated, then the context of the current
// walk must not start from the 'Disconnected' state.
assert (walkStateGraphContext.walkedStateGraphPath.get(0).stateDescriptor.getClass() != DisconnectedStateDescriptor.class);
assert walkStateGraphContext.walkedStateGraphPath.get(0).stateDescriptor.getClass() != DisconnectedStateDescriptor.class;
walkFromDisconnectToAuthenticated.addAll(walkStateGraphContext.walkedStateGraphPath);
} else {
walkFromDisconnectToAuthenticated = new ArrayList<>(walkStateGraphContext.walkedStateGraphPath.size() + 1);

View file

@ -326,7 +326,7 @@ public class StateDescriptorGraph {
private static <E> List<GraphVertex<E>> topologicalSort(Collection<GraphVertex<E>> vertexes) {
List<GraphVertex<E>> res = new ArrayList<>();
dfs(vertexes, (vertex) -> res.add(0, vertex), null);
dfs(vertexes, vertex -> res.add(0, vertex), null);
return res;
}
@ -365,7 +365,7 @@ public class StateDescriptorGraph {
PrintWriter dotOut, boolean breakStateName) {
dotOut.append("digraph {\n");
dfs(vertexes,
(finishedVertex) -> {
finishedVertex -> {
boolean isMultiVisitState = finishedVertex.element.isMultiVisitState();
boolean isFinalState = finishedVertex.element.isFinalState();
boolean isNotImplemented = finishedVertex.element.isNotImplemented();

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2014 Florian Schmaus
* Copyright © 2014-2019 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -119,6 +119,6 @@ public class StreamOpen implements Nonza {
public enum StreamContentNamespace {
client,
server;
server,
}
}

View file

@ -152,7 +152,7 @@ public abstract class SASLMechanism implements Comparable<SASLMechanism> {
this.password = password;
this.authorizationId = authzid;
this.sslSession = sslSession;
assert (authorizationId == null || authzidSupported());
assert authorizationId == null || authzidSupported();
authenticateInternal();
authenticate();
}
@ -179,7 +179,7 @@ public abstract class SASLMechanism implements Comparable<SASLMechanism> {
this.serviceName = serviceName;
this.authorizationId = authzid;
this.sslSession = sslSession;
assert (authorizationId == null || authzidSupported());
assert authorizationId == null || authzidSupported();
authenticateInternal(cbh);
authenticate();
}

View file

@ -228,7 +228,7 @@ public abstract class ScramMechanism extends SASLMechanism {
}
String cbName = getChannelBindingName();
assert (StringUtils.isNotEmpty(cbName));
assert StringUtils.isNotEmpty(cbName);
return cbName + ',' + authzidPortion + ",";
}

View file

@ -233,7 +233,7 @@ public class DNSUtil {
}
for (SRVRecord r : bucket) {
running_total += (r.getWeight() + zeroWeight);
running_total += r.getWeight() + zeroWeight;
totals[count] = running_total;
count++;
}

View file

@ -148,7 +148,7 @@ public class MultiMap<K, V> {
if (res == null) {
return null;
}
assert (!res.isEmpty());
assert !res.isEmpty();
return res.iterator().next();
}

View file

@ -137,7 +137,7 @@ public class PacketParserUtils {
*/
public static Message parseMessage(XmlPullParser parser, XmlEnvironment outerXmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
ParserUtils.assertAtStartTag(parser);
assert (parser.getName().equals(Message.ELEMENT));
assert parser.getName().equals(Message.ELEMENT);
XmlEnvironment messageXmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
final int initialDepth = parser.getDepth();
@ -218,7 +218,7 @@ public class PacketParserUtils {
* @throws IOException
*/
public static String parseElementText(XmlPullParser parser) throws XmlPullParserException, IOException {
assert (parser.getEventType() == XmlPullParser.Event.START_ELEMENT);
assert parser.getEventType() == XmlPullParser.Event.START_ELEMENT;
String res;
// Advance to the text of the Element
XmlPullParser.Event event = parser.next();
@ -263,7 +263,7 @@ public class PacketParserUtils {
public static CharSequence parseElement(XmlPullParser parser,
boolean fullNamespaces) throws XmlPullParserException,
IOException {
assert (parser.getEventType() == XmlPullParser.Event.START_ELEMENT);
assert parser.getEventType() == XmlPullParser.Event.START_ELEMENT;
return parseContentDepth(parser, parser.getDepth(), fullNamespaces);
}
@ -631,7 +631,7 @@ public class PacketParserUtils {
*/
public static Compress.Feature parseCompressionFeature(XmlPullParser parser)
throws IOException, XmlPullParserException {
assert (parser.getEventType() == XmlPullParser.Event.START_ELEMENT);
assert parser.getEventType() == XmlPullParser.Event.START_ELEMENT;
String name;
final int initialDepth = parser.getDepth();
List<String> methods = new LinkedList<>();
@ -660,8 +660,8 @@ public class PacketParserUtils {
break;
}
}
assert (parser.getEventType() == XmlPullParser.Event.END_ELEMENT);
assert (parser.getDepth() == initialDepth);
assert parser.getEventType() == XmlPullParser.Event.END_ELEMENT;
assert parser.getDepth() == initialDepth;
return new Compress.Feature(methods);
}
@ -679,7 +679,7 @@ public class PacketParserUtils {
String text = parser.nextText();
String previousValue = descriptiveTexts.put(xmllang, text);
assert (previousValue == null);
assert previousValue == null;
return descriptiveTexts;
}
@ -704,7 +704,7 @@ public class PacketParserUtils {
descriptiveTexts = parseDescriptiveTexts(parser, descriptiveTexts);
}
else {
assert (condition == null);
assert condition == null;
condition = parser.getName();
}
break;
@ -875,8 +875,8 @@ public class PacketParserUtils {
public static StartTls parseStartTlsFeature(XmlPullParser parser)
throws XmlPullParserException, IOException {
assert (parser.getEventType() == XmlPullParser.Event.START_ELEMENT);
assert (parser.getNamespace().equals(StartTls.NAMESPACE));
ParserUtils.assertAtStartTag(parser);
assert parser.getNamespace().equals(StartTls.NAMESPACE);
int initalDepth = parser.getDepth();
boolean required = false;
outerloop: while (true) {
@ -900,7 +900,7 @@ public class PacketParserUtils {
break;
}
}
assert (parser.getEventType() == XmlPullParser.Event.END_ELEMENT);
ParserUtils.assertAtEndTag(parser);
return new StartTls(required);
}

View file

@ -50,7 +50,7 @@ public class ParserUtils {
public static final String JID = "jid";
public static void assertAtStartTag(XmlPullParser parser) throws XmlPullParserException {
assert (parser.getEventType() == XmlPullParser.Event.START_ELEMENT);
assert parser.getEventType() == XmlPullParser.Event.START_ELEMENT;
}
public static void assertAtStartTag(XmlPullParser parser, String name) throws XmlPullParserException {
@ -59,7 +59,7 @@ public class ParserUtils {
}
public static void assertAtEndTag(XmlPullParser parser) throws XmlPullParserException {
assert (parser.getEventType() == XmlPullParser.Event.END_ELEMENT);
assert parser.getEventType() == XmlPullParser.Event.END_ELEMENT;
}
public static void forwardToEndTagOfDepth(XmlPullParser parser, int depth)

View file

@ -110,7 +110,6 @@ public class StringUtils {
forAttribute,
forAttributeApos,
forText,
;
}
/**

View file

@ -180,7 +180,7 @@ public class XmlStringBuilder implements Appendable, CharSequence, Element {
}
public XmlStringBuilder halfOpenElement(String name) {
assert (StringUtils.isNotEmpty(name));
assert StringUtils.isNotEmpty(name);
sb.append('<').append(name);
return this;
}

View file

@ -111,7 +111,7 @@ public class HostAddress {
public void setException(InetAddress inetAddress, Exception exception) {
Exception old = exceptions.put(inetAddress, exception);
assert (old == null);
assert old == null;
}
/**

View file

@ -114,14 +114,14 @@ public class SmackTestUtil {
public static XmlPullParser getParserFor(String xml, QName startTagQName, XmlPullParserKind parserKind)
throws XmlPullParserException, IOException {
XmlPullParser parser = getParserFor(xml, parserKind);
forwardParserToStartElement(parser, (p) -> p.getQName().equals(startTagQName));
forwardParserToStartElement(parser, p -> p.getQName().equals(startTagQName));
return parser;
}
public static XmlPullParser getParserFor(String xml, String startTagLocalpart, XmlPullParserKind parserKind)
throws XmlPullParserException, IOException {
XmlPullParser parser = getParserFor(xml, parserKind);
forwardParserToStartElement(parser, (p) -> p.getName().equals(startTagLocalpart));
forwardParserToStartElement(parser, p -> p.getName().equals(startTagLocalpart));
return parser;
}

View file

@ -138,7 +138,7 @@ public final class CarbonManager extends Manager {
// also reset here.
enabled_state = false;
boolean removed = connection().removeSyncStanzaListener(carbonsListener);
assert (removed);
assert removed;
}
@Override
public void authenticated(XMPPConnection connection, boolean resumed) {

View file

@ -62,7 +62,7 @@ public final class EligibleForChatMarkerFilter extends StanzaExtensionFilter {
ChatState state;
try {
state = ChatState.valueOf(chatStateElementName);
return (state == ChatState.active);
return state == ChatState.active;
}
catch (Exception ex) {
return false;

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2017 Florian Schmaus
* Copyright 2017-2019 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,6 +22,5 @@ public enum MessageProcessingHintType {
no_store,
no_copy,
store,
;
}

View file

@ -134,7 +134,7 @@ public final class HttpFileUploadManager extends Manager {
}
private static UploadService uploadServiceFrom(DiscoverInfo discoverInfo) {
assert (containsHttpFileUploadNamespace(discoverInfo));
assert containsHttpFileUploadNamespace(discoverInfo);
UploadService.Version version;
if (discoverInfo.containsFeature(NAMESPACE)) {

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2016 Florian Schmaus
* Copyright 2016-2019 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -316,7 +316,7 @@ public final class IoTProvisioningManager extends Manager {
return null;
}
Jid jid = discoverInfos.get(0).getFrom();
assert (jid.isDomainBareJid());
assert jid.isDomainBareJid();
return jid.asDomainBareJid();
}
@ -341,7 +341,7 @@ public final class IoTProvisioningManager extends Manager {
IoTIsFriend iotIsFriend = new IoTIsFriend(friendInQuestion);
iotIsFriend.setTo(provisioningServer);
IoTIsFriendResponse response = connection().createStanzaCollectorAndSend(iotIsFriend).nextResultOrThrow();
assert (response.getJid().equals(friendInQuestion));
assert response.getJid().equals(friendInQuestion);
boolean isFriend = response.getIsFriendResult();
if (!isFriend) {
// Cache the negative is friend response.

View file

@ -39,7 +39,6 @@ public class MamPrefsIQ extends IQ {
always,
never,
roster,
;
}
/**

View file

@ -48,7 +48,7 @@ public class MamResultFilter extends FlexibleStanzaTypeFilter<Message> {
}
String resultQueryId = mamResultExtension.getQueryId();
return ((queryId == null && resultQueryId == null) || (queryId != null && queryId.equals(resultQueryId)));
return (queryId == null && resultQueryId == null) || (queryId != null && queryId.equals(resultQueryId));
}
}

View file

@ -65,7 +65,7 @@ public class AbstractHttpOverXmppProviderTest {
IQ iq = provider.parse(parser);
assertTrue(iq instanceof HttpOverXmppResp);
HttpOverXmppResp body = ((HttpOverXmppResp) iq);
HttpOverXmppResp body = (HttpOverXmppResp) iq;
checkHeaders(body.getHeaders(), expectedHeaders);
}
@ -85,7 +85,7 @@ public class AbstractHttpOverXmppProviderTest {
IQ iq = provider.parse(parser);
assertTrue(iq instanceof HttpOverXmppReq);
HttpOverXmppReq body = ((HttpOverXmppReq) iq);
HttpOverXmppReq body = (HttpOverXmppReq) iq;
checkHeaders(body.getHeaders(), expectedHeaders);
}

View file

@ -79,7 +79,7 @@ public class ServiceAdministrationManager extends Manager {
answerForm.setAnswer("password-verify", password);
command.execute(answerForm);
assert (command.isCompleted());
assert command.isCompleted();
}
public RemoteCommand deleteUser() {
@ -106,6 +106,6 @@ public class ServiceAdministrationManager extends Manager {
answerForm.setAnswer("accountjids", jidsToDelete);
command.execute(answerForm);
assert (command.isCompleted());
assert command.isCompleted();
}
}

View file

@ -82,7 +82,7 @@ public class BoBData {
private void setContentBinaryIfRequired() {
if (contentBinary == null) {
assert (StringUtils.isNotEmpty(contentString));
assert StringUtils.isNotEmpty(contentString);
contentBinary = Base64.decode(contentString);
}
}

View file

@ -757,7 +757,7 @@ public class InBandBytestreamSession implements BytestreamSession {
bufferPointer = 0;
// increment sequence, considering sequence overflow
this.seq = (this.seq + 1 == 65535 ? 0 : this.seq + 1);
this.seq = this.seq + 1 == 65535 ? 0 : this.seq + 1;
}

View file

@ -33,7 +33,7 @@ public abstract class AbstractDelayInformationProvider extends ExtensionElementP
public final DelayInformation parse(XmlPullParser parser,
int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException,
IOException, SmackTextParseException {
String stampString = (parser.getAttributeValue("", "stamp"));
String stampString = parser.getAttributeValue("", "stamp");
String from = parser.getAttributeValue("", "from");
final String reason;
XmlPullParser.Event event = parser.next();

View file

@ -79,7 +79,7 @@ public class DiscoverInfoProvider extends IQProvider<DiscoverInfo> {
if (parser.getName().equals("feature")) {
// Create a new feature and add it to the discovered info.
boolean notADuplicateFeature = discoverInfo.addFeature(variable);
assert (notADuplicateFeature);
assert notADuplicateFeature;
}
if (parser.getName().equals("query")) {
done = true;

View file

@ -73,7 +73,7 @@ public final class FileTransferNegotiator extends Manager {
* set this variable to true for testing purposes as IBB is the backup file transfer method
* and shouldn't be used as the only transfer method in production systems.
*/
public static boolean IBB_ONLY = (System.getProperty("ibb") != null);//true;
public static boolean IBB_ONLY = System.getProperty("ibb") != null;//true;
/**
* Returns the file transfer negotiator related to a particular connection.

View file

@ -214,7 +214,7 @@ public final class LastActivityManager extends Manager {
private long getIdleTime() {
long lms = lastMessageSent;
long now = System.currentTimeMillis();
return ((now - lms) / 1000);
return (now - lms) / 1000;
}
/**

View file

@ -19,5 +19,4 @@ package org.jivesoftware.smackx.jingle;
public enum Role {
initiator,
responder,
;
}

View file

@ -208,7 +208,7 @@ public class RoomInfo {
FormField subjectmodField = form.getField("muc#roominfo_subjectmod");
if (subjectmodField != null && !subjectmodField.getValues().isEmpty()) {
String firstValue = subjectmodField.getFirstValue();
subjectmod = ("true".equals(firstValue) || "1".equals(firstValue));
subjectmod = "true".equals(firstValue) || "1".equals(firstValue);
}
FormField urlField = form.getField("muc#roominfo_logs");

View file

@ -104,9 +104,9 @@ public final class PepManager extends Manager {
public void processStanza(Stanza stanza) {
final Message message = (Message) stanza;
final EventElement event = EventElement.from(stanza);
assert (event != null);
assert event != null;
final EntityBareJid from = message.getFrom().asEntityBareJidIfPossible();
assert (from != null);
assert from != null;
asyncButOrdered.performAsyncButOrdered(from, new Runnable() {
@Override
public void run() {

View file

@ -37,5 +37,5 @@ public enum AccessModel {
roster,
/** Only those on a whitelist may subscribe and retrieve items. */
whitelist;
whitelist,
}

View file

@ -167,7 +167,7 @@ public class Affiliation implements ExtensionElement {
*/
public boolean isAffiliationModification() {
if (jid != null && affiliation != null) {
assert (node == null && namespace == AffiliationNamespace.owner);
assert node == null && namespace == AffiliationNamespace.owner;
return true;
}
return false;

View file

@ -30,5 +30,5 @@ public enum ChildrenAssociationPolicy {
owners,
/** Only those on a whitelist may associate leaf nodes with the collection. */
whitelist;
whitelist,
}

View file

@ -50,6 +50,6 @@ public class ConfigurationEvent extends NodeExtension implements EmbeddedPacketE
if (getConfiguration() == null)
return Collections.emptyList();
else
return Arrays.asList(((ExtensionElement) getConfiguration().getDataFormToSend()));
return Arrays.asList((ExtensionElement) getConfiguration().getDataFormToSend());
}
}

View file

@ -19,6 +19,7 @@ package org.jivesoftware.smackx.pubsub;
import java.util.ArrayList;
import java.util.List;
import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.packet.DataForm;
@ -246,7 +247,7 @@ public class ConfigureForm extends Form {
* @return true if it does, false otherwise
*/
public boolean isDeliverPayloads() {
return parseBoolean(getFieldValue(ConfigureNodeFields.deliver_payloads));
return ParserUtils.parseXmlBoolean(getFieldValue(ConfigureNodeFields.deliver_payloads));
}
/**
@ -353,7 +354,7 @@ public class ConfigureForm extends Form {
* @return true if they should be notified, false otherwise
*/
public boolean isNotifyConfig() {
return parseBoolean(getFieldValue(ConfigureNodeFields.notify_config));
return ParserUtils.parseXmlBoolean(getFieldValue(ConfigureNodeFields.notify_config));
}
/**
@ -372,7 +373,7 @@ public class ConfigureForm extends Form {
* @return true if subscribers should be notified, false otherwise
*/
public boolean isNotifyDelete() {
return parseBoolean(getFieldValue(ConfigureNodeFields.notify_delete));
return ParserUtils.parseXmlBoolean(getFieldValue(ConfigureNodeFields.notify_delete));
}
/**
@ -392,7 +393,7 @@ public class ConfigureForm extends Form {
* @return true if subscribers should be notified, false otherwise
*/
public boolean isNotifyRetract() {
return parseBoolean(getFieldValue(ConfigureNodeFields.notify_retract));
return ParserUtils.parseXmlBoolean(getFieldValue(ConfigureNodeFields.notify_retract));
}
/**
@ -436,7 +437,7 @@ public class ConfigureForm extends Form {
* @return true if items are persisted
*/
public boolean isPersistItems() {
return parseBoolean(getFieldValue(ConfigureNodeFields.persist_items));
return ParserUtils.parseXmlBoolean(getFieldValue(ConfigureNodeFields.persist_items));
}
/**
@ -455,7 +456,7 @@ public class ConfigureForm extends Form {
* @return true if users must be available
*/
public boolean isPresenceBasedDelivery() {
return parseBoolean(getFieldValue(ConfigureNodeFields.presence_based_delivery));
return ParserUtils.parseXmlBoolean(getFieldValue(ConfigureNodeFields.presence_based_delivery));
}
/**
@ -566,7 +567,7 @@ public class ConfigureForm extends Form {
* @return true if subscriptions are allowed, false otherwise
*/
public boolean isSubscribe() {
return parseBoolean(getFieldValue(ConfigureNodeFields.subscribe));
return ParserUtils.parseXmlBoolean(getFieldValue(ConfigureNodeFields.subscribe));
}
/**
@ -645,10 +646,6 @@ public class ConfigureForm extends Form {
return result.toString();
}
private static boolean parseBoolean(String fieldValue) {
return ("1".equals(fieldValue) || "true".equals(fieldValue));
}
private String getFieldValue(ConfigureNodeFields field) {
FormField formField = getField(field.getFieldName());

View file

@ -96,7 +96,7 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent {
* @return true if the items are delayed, false otherwise.
*/
public boolean isDelayed() {
return (originalDate != null);
return originalDate != null;
}
/**

View file

@ -305,7 +305,7 @@ public class LeafNode extends Node {
@SuppressWarnings("unchecked")
public <T extends Item> void publish(T item) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Collection<T> items = new ArrayList<>(1);
items.add((item == null ? (T) new Item() : item));
items.add(item == null ? (T) new Item() : item);
publish(items);
}

View file

@ -70,7 +70,7 @@ public enum PubSubElementType {
public static PubSubElementType valueOfFromElemName(String elemName, String namespace) {
int index = namespace.lastIndexOf('#');
String fragment = (index == -1 ? null : namespace.substring(index + 1));
String fragment = index == -1 ? null : namespace.substring(index + 1);
if (fragment != null) {
return valueOf((elemName + '_' + fragment).toUpperCase(Locale.US));

View file

@ -23,6 +23,7 @@ import java.util.Date;
import java.util.List;
import java.util.UnknownFormatConversionException;
import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.packet.DataForm;
@ -58,7 +59,7 @@ public class SubscribeForm extends Form {
* @return true if want to receive, false otherwise
*/
public boolean isDeliverOn() {
return parseBoolean(getFieldValue(SubscribeOptionFields.deliver));
return ParserUtils.parseXmlBoolean(getFieldValue(SubscribeOptionFields.deliver));
}
/**
@ -77,7 +78,7 @@ public class SubscribeForm extends Form {
* @return true to aggregate, false otherwise
*/
public boolean isDigestOn() {
return parseBoolean(getFieldValue(SubscribeOptionFields.digest));
return ParserUtils.parseXmlBoolean(getFieldValue(SubscribeOptionFields.digest));
}
/**
@ -143,7 +144,7 @@ public class SubscribeForm extends Form {
* @return true to receive the message body, false otherwise
*/
public boolean isIncludeBody() {
return parseBoolean(getFieldValue(SubscribeOptionFields.include_body));
return ParserUtils.parseXmlBoolean(getFieldValue(SubscribeOptionFields.include_body));
}
/**
@ -188,11 +189,6 @@ public class SubscribeForm extends Form {
setAnswer(SubscribeOptionFields.show_values.getFieldName(), values);
}
private static boolean parseBoolean(String fieldValue) {
return ("1".equals(fieldValue) || "true".equals(fieldValue));
}
private String getFieldValue(SubscribeOptionFields field) {
FormField formField = getField(field.getFieldName());

View file

@ -55,7 +55,7 @@ public class SubscriptionProvider extends ExtensionElementProvider<Subscription>
while (tag != XmlPullParser.Event.END_ELEMENT && !parser.getName().equals("subscribe-options")) tag = parser.next();
}
while (parser.getEventType() != XmlPullParser.Event.END_ELEMENT) parser.next();
return new Subscription(jid, nodeId, subId, (state == null ? null : Subscription.State.valueOf(state)), isRequired);
return new Subscription(jid, nodeId, subId, state == null ? null : Subscription.State.valueOf(state), isRequired);
}
}

View file

@ -309,7 +309,7 @@ public final class DeliveryReceiptManager extends Manager {
* @return true if a delivery receipt was requested
*/
public static boolean hasDeliveryReceiptRequest(Message message) {
return (DeliveryReceiptRequest.from(message) != null);
return DeliveryReceiptRequest.from(message) != null;
}
/**

View file

@ -26,7 +26,7 @@ public class MucMemoryLeakTest extends SmackTestSuite {
@Test
public void mucMemoryLeakTest() throws XmppStringprepException, IllegalArgumentException, InterruptedException {
MemoryLeakTestUtil.noResourceLeakTest((c) -> MultiUserChatManager.getInstanceFor(c));
MemoryLeakTestUtil.noResourceLeakTest(c -> MultiUserChatManager.getInstanceFor(c));
}
}

View file

@ -103,7 +103,7 @@ public final class ChatManager extends Manager{
* Will attempt to match on the JID in the from field, and then attempt the base JID if no match was found.
* This is the most lenient matching.
*/
BARE_JID;
BARE_JID,
}
private final StanzaFilter packetFilter = new OrFilter(MessageTypeFilter.CHAT, new FlexibleStanzaTypeFilter<Message>() {

View file

@ -1570,7 +1570,7 @@ public final class Roster extends Manager {
else {
fullFrom = from.asFullJidIfPossible();
// We know that this must be a full JID in this case.
assert (fullFrom != null);
assert fullFrom != null;
}
}
Map<Resourcepart, Presence> userPresences;

View file

@ -123,7 +123,7 @@ public final class RosterEntry extends Manager {
* @param item new item
*/
void updateItem(RosterPacket.Item item) {
assert (item != null);
assert item != null;
this.item = item;
}

View file

@ -113,7 +113,7 @@ public class RosterPacketProvider extends IQProvider<RosterPacket> {
}
}
ParserUtils.assertAtEndTag(parser);
assert (item != null);
assert item != null;
return item;
}
}

View file

@ -149,7 +149,7 @@ public final class Configuration {
this.disabledTests = disabledTests;
this.testPackages = testPackages;
this.configurationApplier = (builder) -> {
this.configurationApplier = builder -> {
if (tlsContext != null) {
builder.setCustomSSLContext(tlsContext);
}

View file

@ -592,7 +592,7 @@ public class SmackIntegrationTestFramework<DC extends AbstractXMPPConnection> {
}
final String className = clz.getName();
final String unqualifiedClassName = clz.getSimpleName();
return (classes.contains(className) || classes.contains(unqualifiedClassName));
return classes.contains(className) || classes.contains(unqualifiedClassName);
}
public static final class TestRunResult {
@ -709,7 +709,7 @@ public class SmackIntegrationTestFramework<DC extends AbstractXMPPConnection> {
this.testMethod = testMethod;
smackIntegrationTestAnnotation = testMethod.getAnnotation(SmackIntegrationTest.class);
assert (smackIntegrationTestAnnotation != null);
assert smackIntegrationTestAnnotation != null;
parameterListOfConnections = testMethodParametersIsListOfConnections(testMethod);
}

View file

@ -28,7 +28,7 @@ public abstract class TestResult {
public TestResult(SmackIntegrationTestFramework.ConcreteTest concreteTest, long startTime, long endTime, List<String> logMessages) {
this.concreteTest = concreteTest;
assert (endTime >= startTime);
assert endTime >= startTime;
this.startTime = startTime;
this.endTime = endTime;
this.duration = endTime - startTime;

View file

@ -283,7 +283,7 @@ public class XmppConnectionManager<DC extends AbstractXMPPConnection> {
registerAccount(finalAccountUsername, finalAccountPassword);
}
DC mainConnection = defaultConnectionDescriptor.construct(sinttestConfiguration, (builder) -> {
DC mainConnection = defaultConnectionDescriptor.construct(sinttestConfiguration, builder -> {
try {
builder.setUsernameAndPassword(finalAccountUsername, finalAccountPassword)
.setResource(middlefix + '-' + testRunId);
@ -398,7 +398,7 @@ public class XmppConnectionManager<DC extends AbstractXMPPConnection> {
throw new IllegalArgumentException(e);
}
ConnectionConfigurationBuilderApplier usernameAndPasswordApplier = (configurationBuilder) -> {
ConnectionConfigurationBuilderApplier usernameAndPasswordApplier = configurationBuilder -> {
configurationBuilder.setUsernameAndPassword(username, password);
};

View file

@ -354,7 +354,7 @@ public class MediaNegotiator extends JingleNegotiator {
* @return true if the content is fully negotiated.
*/
public boolean isFullyEstablished() {
return (isEstablished() && ((getNegotiatorState() == JingleNegotiatorState.SUCCEEDED) || (getNegotiatorState() == JingleNegotiatorState.FAILED)));
return isEstablished() && ((getNegotiatorState() == JingleNegotiatorState.SUCCEEDED) || (getNegotiatorState() == JingleNegotiatorState.FAILED));
}
// Payload types

View file

@ -164,7 +164,7 @@ public class ImageTransmitter implements Runnable {
}
}
trace = (System.currentTimeMillis() - trace);
trace = System.currentTimeMillis() - trace;
LOGGER.fine("Loop Time:" + trace);
if (trace < 500) {

View file

@ -648,7 +648,7 @@ public abstract class TransportCandidate {
this.id = session.getSid();
this.candidate = candidate;
int keySplitIndex = ((int) Math.ceil(((float) id.length()) / 2));
int keySplitIndex = (int) Math.ceil(((float) id.length()) / 2);
String local = id.substring(0, keySplitIndex) + ";" + localUser;
String remote = id.substring(keySplitIndex) + ";" + remoteUser;

View file

@ -281,7 +281,7 @@ public abstract class TransportNegotiator extends JingleNegotiator {
* @return true if the transport is fully established.
*/
public final boolean isFullyEstablished() {
return (isEstablished() && ((getNegotiatorState() == JingleNegotiatorState.SUCCEEDED) || (getNegotiatorState() == JingleNegotiatorState.FAILED)));
return isEstablished() && ((getNegotiatorState() == JingleNegotiatorState.SUCCEEDED) || (getNegotiatorState() == JingleNegotiatorState.FAILED));
}
/**
@ -303,7 +303,7 @@ public abstract class TransportNegotiator extends JingleNegotiator {
// Sleep for some time, waiting for the candidates checks
int totalTime = (CANDIDATES_ACCEPT_PERIOD + TransportResolver.CHECK_TIMEOUT);
int totalTime = CANDIDATES_ACCEPT_PERIOD + TransportResolver.CHECK_TIMEOUT;
int tries = (int) Math.ceil(totalTime / 1000);
for (int i = 0; i < tries - 1; i++) {

View file

@ -78,7 +78,7 @@ public class OfflineSettings extends SimpleIQ {
}
public boolean redirects() {
return (StringUtils.isNotEmpty(getRedirectURL()));
return StringUtils.isNotEmpty(getRedirectURL());
}
public boolean isConfigured() {

View file

@ -149,8 +149,8 @@ public class SignalOmemoRatchet
}
// TODO: Figure out, if this is enough...
int type = (ciphertextMessage.getType() == CiphertextMessage.PREKEY_TYPE ?
OmemoElement.TYPE_OMEMO_PREKEY_MESSAGE : OmemoElement.TYPE_OMEMO_MESSAGE);
int type = ciphertextMessage.getType() == CiphertextMessage.PREKEY_TYPE ?
OmemoElement.TYPE_OMEMO_PREKEY_MESSAGE : OmemoElement.TYPE_OMEMO_MESSAGE;
return new CiphertextTuple(ciphertextMessage.serialize(), type);
}

View file

@ -135,7 +135,7 @@ public class SignalOmemoStoreConnector
@Override
public boolean containsPreKey(int i) {
try {
return (loadPreKey(i) != null);
return loadPreKey(i) != null;
} catch (InvalidKeyIdException e) {
return false;
}

View file

@ -113,7 +113,7 @@ public abstract class FileBasedOmemoStore<T_IdKeyPair, T_IdKey, T_PreKey, T_SigP
SortedSet<Integer> deviceIds = new TreeSet<>();
File userDir = hierarchy.getUserDirectory(localUser);
File[] list = userDir.listFiles();
for (File d : (list != null ? list : new File[] {})) {
for (File d : list != null ? list : new File[] {}) {
if (d.isDirectory()) {
try {
deviceIds.add(Integer.parseInt(d.getName()));

View file

@ -60,7 +60,6 @@ public class OpenPgpMessage {
* Represents a {@link CryptElement}.
*/
crypt,
;
}
private final String element;

View file

@ -160,7 +160,7 @@ public abstract class OpenPgpContentElement implements ExtensionElement {
}
protected void addCommonXml(XmlStringBuilder xml) {
for (Jid toJid : (to != null ? to : Collections.<Jid>emptySet())) {
for (Jid toJid : to != null ? to : Collections.<Jid>emptySet()) {
xml.halfOpenElement(ELEM_TO).attribute(ATTR_JID, toJid).closeEmptyElement();
}

View file

@ -173,7 +173,7 @@ public class SASLDigestMD5Mechanism extends SASLMechanism {
String serverResponse = null;
for (String part : challengeParts) {
String[] keyValue = part.split("=");
assert (keyValue.length == 2);
assert keyValue.length == 2;
String key = keyValue[0];
String value = keyValue[1];
if ("rspauth".equals(key)) {

View file

@ -569,7 +569,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
int port = hostAddress.getPort();
if (proxyInfo == null) {
inetAddresses = hostAddress.getInetAddresses().iterator();
assert (inetAddresses.hasNext());
assert inetAddresses.hasNext();
innerloop: while (inetAddresses.hasNext()) {
// Create a *new* Socket before every connection attempt, i.e. connect() call, since Sockets are not

View file

@ -229,7 +229,7 @@ public class XmppNioTcpConnection extends AbstractXmppNioConnection {
notifyConnectionError(ise);
return;
}
assert (config.getXMPPServiceDomain().equals(reportedServerDomain));
assert config.getXMPPServiceDomain().equals(reportedServerDomain);
break;
case "xmlns":
streamOpen.append(" xmlns='").append(attributeValue).append('\'');
@ -513,7 +513,7 @@ public class XmppNioTcpConnection extends AbstractXmppNioConnection {
} else {
outgoingCharSequenceIterator = Collections.singletonList(nextCharSequence).iterator();
}
assert (outgoingCharSequenceIterator != null);
assert outgoingCharSequenceIterator != null;
} else {
// There is nothing more to write.
break;
@ -1067,7 +1067,6 @@ public class XmppNioTcpConnection extends AbstractXmppNioConnection {
initiated,
successful,
failed,
;
}
private static final Level SSL_ENGINE_DEBUG_LOG_LEVEL = Level.FINEST;
@ -1282,7 +1281,7 @@ public class XmppNioTcpConnection extends AbstractXmppNioConnection {
return null;
case BUFFER_OVERFLOW:
int applicationBufferSize = engine.getSession().getApplicationBufferSize();
assert (peerAppData.remaining() < applicationBufferSize);
assert peerAppData.remaining() < applicationBufferSize;
peerAppData = ByteBuffer.allocate(applicationBufferSize);
continue;
}