1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-25 15:52:06 +01:00

Make Filters fields final and use StringUtils

This commit is contained in:
Florian Schmaus 2014-12-09 14:11:33 +01:00
parent 1c08d1c594
commit c9bf420b37
6 changed files with 14 additions and 11 deletions

View file

@ -28,7 +28,7 @@ import org.jivesoftware.smack.packet.Packet;
*/
public abstract class FlexiblePacketTypeFilter<P extends Packet> implements PacketFilter {
final Class<P> packetType;
protected final Class<P> packetType;
public FlexiblePacketTypeFilter(Class<P> packetType) {
this.packetType = packetType;

View file

@ -32,11 +32,12 @@ import org.jxmpp.util.XmppStringUtils;
*/
public class FromMatchesFilter implements PacketFilter {
private String address;
private final String address;
/**
* Flag that indicates if the checking will be done against bare JID addresses or full JIDs.
*/
private boolean matchBareJID = false;
private final boolean matchBareJID;
/**
* Creates a filter matching on the "from" field. The from address must be the same as the

View file

@ -27,7 +27,7 @@ import org.jivesoftware.smack.packet.Packet;
*/
public class NotFilter implements PacketFilter {
private PacketFilter filter;
private final PacketFilter filter;
/**
* Creates a NOT filter using the specified filter.

View file

@ -18,6 +18,7 @@
package org.jivesoftware.smack.filter;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.util.StringUtils;
/**
* Filters for packets with a particular packet ID.
@ -26,7 +27,7 @@ import org.jivesoftware.smack.packet.Packet;
*/
public class PacketIDFilter implements PacketFilter {
private String packetID;
private final String packetID;
/**
* Creates a new packet ID filter using the specified packet's ID.
@ -43,8 +44,8 @@ public class PacketIDFilter implements PacketFilter {
* @param packetID the packet ID to filter for.
*/
public PacketIDFilter(String packetID) {
if (packetID == null) {
throw new IllegalArgumentException("Packet ID must not be null.");
if (StringUtils.isNullOrEmpty(packetID)) {
throw new IllegalArgumentException("Packet ID must not be null or empty.");
}
this.packetID = packetID;
}

View file

@ -37,7 +37,7 @@ public class PacketTypeFilter implements PacketFilter {
public static final PacketTypeFilter PRESENCE = new PacketTypeFilter(Presence.class);
public static final PacketTypeFilter MESSAGE = new PacketTypeFilter(Message.class);
Class<? extends Packet> packetType;
private final Class<? extends Packet> packetType;
/**
* Creates a new packet type filter that will filter for packets that are the

View file

@ -19,6 +19,7 @@ package org.jivesoftware.smack.filter;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.util.StringUtils;
/**
* Filters for message packets with a particular thread value.
@ -27,7 +28,7 @@ import org.jivesoftware.smack.packet.Message;
*/
public class ThreadFilter implements PacketFilter {
private String thread;
private final String thread;
/**
* Creates a new thread filter using the specified thread value.
@ -35,8 +36,8 @@ public class ThreadFilter implements PacketFilter {
* @param thread the thread value to filter for.
*/
public ThreadFilter(String thread) {
if (thread == null) {
throw new IllegalArgumentException("Thread must not be null.");
if (StringUtils.isNullOrEmpty(thread)) {
throw new IllegalArgumentException("Thread must not be null or empty.");
}
this.thread = thread;
}