Skip to content

Commit

Permalink
Use Java API for Function, Predicate, and Supplier
Browse files Browse the repository at this point in the history
  • Loading branch information
Flowdalic committed Oct 26, 2024
1 parent 9943f66 commit eb8e18e
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.net.InetAddress;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;

import javax.xml.namespace.QName;

Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand All @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -315,7 +315,7 @@ public static IqData buildIqData(String stanzaId) {
return new IqData(stanzaId);
}

public static <SB extends StanzaBuilder<?>> SB buildResponse(StanzaView request, Function<SB, String> builderFromStanzaId) {
public static <SB extends StanzaBuilder<?>> SB buildResponse(StanzaView request, Function<String, SB> builderFromStanzaId) {
SB responseBuilder = builderFromStanzaId.apply(request.getStanzaId());

responseBuilder.to(request.getFrom())
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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 {

Expand All @@ -36,7 +35,7 @@ public interface ProxySocketConnection {
void connect(Socket socket, String host, int port, int timeout)
throws IOException;

static Function<ProxySocketConnection, ProxyInfo> forProxyType(ProxyInfo.ProxyType proxyType) {
static Function<ProxyInfo, ProxySocketConnection> forProxyType(ProxyInfo.ProxyType proxyType) {
switch (proxyType) {
case HTTP:
return HTTPProxySocketConnection::new;
Expand Down
26 changes: 0 additions & 26 deletions smack-core/src/main/java/org/jivesoftware/smack/util/Function.java

This file was deleted.

This file was deleted.

24 changes: 0 additions & 24 deletions smack-core/src/main/java/org/jivesoftware/smack/util/Supplier.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -19,6 +19,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.function.Function;

public class ToStringUtil {

Expand Down Expand Up @@ -46,7 +47,7 @@ public Builder addValue(String name, Object value) {
return this;
}

public <V> Builder add(String name, Collection<? extends V> values, Function<?, V> toStringFunction) {
public <V> Builder add(String name, Collection<? extends V> values, Function<V, ?> toStringFunction) {
if (values.isEmpty()) {
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down

0 comments on commit eb8e18e

Please sign in to comment.