diff --git a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java index e22eed8384..3674d148ad 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java @@ -41,6 +41,8 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; +import java.util.function.Predicate; +import java.util.function.Supplier; import java.util.logging.Level; import java.util.logging.Logger; @@ -114,9 +116,7 @@ import org.jivesoftware.smack.util.Objects; import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smack.util.ParserUtils; -import org.jivesoftware.smack.util.Predicate; import org.jivesoftware.smack.util.StringUtils; -import org.jivesoftware.smack.util.Supplier; import org.jivesoftware.smack.xml.XmlPullParser; import org.jivesoftware.smack.xml.XmlPullParserException; diff --git a/smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java index de5f46477f..efd0a46819 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java @@ -18,6 +18,7 @@ import java.net.InetAddress; import java.util.concurrent.TimeUnit; +import java.util.function.Predicate; import javax.xml.namespace.QName; @@ -39,7 +40,6 @@ import org.jivesoftware.smack.packet.StanzaFactory; import org.jivesoftware.smack.packet.XmlElement; import org.jivesoftware.smack.util.Consumer; -import org.jivesoftware.smack.util.Predicate; import org.jivesoftware.smack.util.XmppElementUtil; import org.jxmpp.jid.DomainBareJid; diff --git a/smack-core/src/main/java/org/jivesoftware/smack/c2s/ModularXmppClientToServerConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/c2s/ModularXmppClientToServerConnection.java index 8cdac17b93..14ccb134ee 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/c2s/ModularXmppClientToServerConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/c2s/ModularXmppClientToServerConnection.java @@ -1,6 +1,6 @@ /** * - * Copyright 2018-2022 Florian Schmaus + * Copyright 2018-2024 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.TimeUnit; +import java.util.function.Supplier; import java.util.logging.Level; import java.util.logging.Logger; @@ -80,7 +81,6 @@ import org.jivesoftware.smack.util.ExtendedAppendable; import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smack.util.StringUtils; -import org.jivesoftware.smack.util.Supplier; import org.jivesoftware.smack.xml.XmlPullParser; import org.jivesoftware.smack.xml.XmlPullParserException; diff --git a/smack-core/src/main/java/org/jivesoftware/smack/c2s/internal/ModularXmppClientToServerConnectionInternal.java b/smack-core/src/main/java/org/jivesoftware/smack/c2s/internal/ModularXmppClientToServerConnectionInternal.java index 42cf9c6508..876932316f 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/c2s/internal/ModularXmppClientToServerConnectionInternal.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/c2s/internal/ModularXmppClientToServerConnectionInternal.java @@ -1,6 +1,6 @@ /** * - * Copyright 2020-2021 Florian Schmaus + * Copyright 2020-2024 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,7 @@ import java.nio.channels.SelectionKey; import java.util.ListIterator; import java.util.Queue; +import java.util.function.Supplier; import org.jivesoftware.smack.SmackException; import org.jivesoftware.smack.SmackException.NoResponseException; @@ -42,7 +43,6 @@ import org.jivesoftware.smack.packet.XmlEnvironment; import org.jivesoftware.smack.util.Consumer; import org.jivesoftware.smack.util.PacketParserUtils; -import org.jivesoftware.smack.util.Supplier; import org.jivesoftware.smack.xml.XmlPullParser; import org.jivesoftware.smack.xml.XmlPullParserException; diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaFilter.java index 147d0c9f1e..b06256f58e 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/StanzaFilter.java @@ -17,8 +17,9 @@ package org.jivesoftware.smack.filter; +import java.util.function.Predicate; + import org.jivesoftware.smack.packet.Stanza; -import org.jivesoftware.smack.util.Predicate; /** * Defines a way to filter stanzas for particular attributes. Stanza filters are used when diff --git a/smack-core/src/main/java/org/jivesoftware/smack/packet/StanzaBuilder.java b/smack-core/src/main/java/org/jivesoftware/smack/packet/StanzaBuilder.java index 2cc2a20edc..4fc57d7b1d 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/packet/StanzaBuilder.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/packet/StanzaBuilder.java @@ -1,6 +1,6 @@ /** * - * Copyright 2019-2021 Florian Schmaus + * Copyright 2019-2024 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,11 +18,11 @@ import java.util.Collection; import java.util.List; +import java.util.function.Function; import javax.xml.namespace.QName; import org.jivesoftware.smack.packet.id.StanzaIdSource; -import org.jivesoftware.smack.util.Function; import org.jivesoftware.smack.util.MultiMap; import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smack.util.ToStringUtil; @@ -315,7 +315,7 @@ public static IqData buildIqData(String stanzaId) { return new IqData(stanzaId); } - public static > SB buildResponse(StanzaView request, Function builderFromStanzaId) { + public static > SB buildResponse(StanzaView request, Function builderFromStanzaId) { SB responseBuilder = builderFromStanzaId.apply(request.getStanzaId()); responseBuilder.to(request.getFrom()) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/proxy/ProxySocketConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/proxy/ProxySocketConnection.java index beaf0ebade..41e6696d22 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/proxy/ProxySocketConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/proxy/ProxySocketConnection.java @@ -1,6 +1,6 @@ /** * - * Copyright 2015-2019 Florian Schmaus. + * Copyright 2015-2024 Florian Schmaus. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,7 @@ import java.io.IOException; import java.net.Socket; - -import org.jivesoftware.smack.util.Function; +import java.util.function.Function; public interface ProxySocketConnection { @@ -36,7 +35,7 @@ public interface ProxySocketConnection { void connect(Socket socket, String host, int port, int timeout) throws IOException; - static Function forProxyType(ProxyInfo.ProxyType proxyType) { + static Function forProxyType(ProxyInfo.ProxyType proxyType) { switch (proxyType) { case HTTP: return HTTPProxySocketConnection::new; diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/Function.java b/smack-core/src/main/java/org/jivesoftware/smack/util/Function.java deleted file mode 100644 index 2cc5552088..0000000000 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/Function.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * - * Copyright 2019-2020 Florian Schmaus - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jivesoftware.smack.util; - -public interface Function { - - R apply(T t); - - static Function identity() { - return t -> t; - } -} diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/Predicate.java b/smack-core/src/main/java/org/jivesoftware/smack/util/Predicate.java deleted file mode 100644 index ad4c11d0c6..0000000000 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/Predicate.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * - * Copyright 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jivesoftware.smack.util; - -// TODO: Replace with java.util.function.Predicate once Smack's minimum Android SDK level is 24 or higher. -public interface Predicate { - - boolean test(T t); - -} diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/Supplier.java b/smack-core/src/main/java/org/jivesoftware/smack/util/Supplier.java deleted file mode 100644 index f0910adb7e..0000000000 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/Supplier.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * - * Copyright 2020 Florian Schmaus - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jivesoftware.smack.util; - -// TODO: Replace with java.util.function.Supplier once Smack's minimum Android SDK level is 24 or higher. -public interface Supplier { - - T get(); - -} diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/ToStringUtil.java b/smack-core/src/main/java/org/jivesoftware/smack/util/ToStringUtil.java index 447f1444f2..f7451cbbfa 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/ToStringUtil.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/ToStringUtil.java @@ -1,6 +1,6 @@ /** * - * Copyright 2019 Florian Schmaus + * Copyright 2019-2024 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.function.Function; public class ToStringUtil { @@ -46,7 +47,7 @@ public Builder addValue(String name, Object value) { return this; } - public Builder add(String name, Collection values, Function toStringFunction) { + public Builder add(String name, Collection values, Function toStringFunction) { if (values.isEmpty()) { return this; } diff --git a/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/Configuration.java b/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/Configuration.java index 3cad302cb7..dc29998f4a 100644 --- a/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/Configuration.java +++ b/smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/Configuration.java @@ -32,6 +32,7 @@ import java.util.Map; import java.util.Properties; import java.util.Set; +import java.util.function.Function; import java.util.logging.Logger; import java.util.stream.Collectors; @@ -41,7 +42,6 @@ import org.jivesoftware.smack.debugger.ConsoleDebugger; import org.jivesoftware.smack.debugger.SmackDebuggerFactory; import org.jivesoftware.smack.util.CollectionUtil; -import org.jivesoftware.smack.util.Function; import org.jivesoftware.smack.util.Objects; import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smack.util.SslContextFactory;