From 61cb73ee3744999fcf7afc3480440bb330d3b9af Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 12 Mar 2021 22:25:50 +0100 Subject: [PATCH] [core] Add AndFilter(List) constructor --- .../smack/filter/AbstractListFilter.java | 13 +++++++++++-- .../org/jivesoftware/smack/filter/AndFilter.java | 13 ++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/AbstractListFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/AbstractListFilter.java index d06ddad47..0d55777ce 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/AbstractListFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/AbstractListFilter.java @@ -1,6 +1,6 @@ /** * - * Copyright 2015 Florian Schmaus + * Copyright 2015-2021 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,11 +44,20 @@ public abstract class AbstractListFilter implements StanzaFilter { * @param filters the filters to add. */ protected AbstractListFilter(StanzaFilter... filters) { + this(new ArrayList(Arrays.asList(filters))); + } + + /** + * Creates an filter using the specified filters. + * + * @param filters the filters to add. + */ + protected AbstractListFilter(List filters) { Objects.requireNonNull(filters, "Parameter must not be null."); for (StanzaFilter filter : filters) { Objects.requireNonNull(filter, "Parameter must not be null."); } - this.filters = new ArrayList(Arrays.asList(filters)); + this.filters = filters; } /** diff --git a/smack-core/src/main/java/org/jivesoftware/smack/filter/AndFilter.java b/smack-core/src/main/java/org/jivesoftware/smack/filter/AndFilter.java index cbdccd6e6..686ce2491 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/filter/AndFilter.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/filter/AndFilter.java @@ -1,6 +1,6 @@ /** * - * Copyright 2003-2007 Jive Software. + * Copyright 2003-2007 Jive Software, 2021 Florian Schmaus. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,8 @@ package org.jivesoftware.smack.filter; +import java.util.List; + import org.jivesoftware.smack.packet.Stanza; /** @@ -44,6 +46,15 @@ public class AndFilter extends AbstractListFilter implements StanzaFilter { super(filters); } + /** + * Creates an AND filter using the specified filters. + * + * @param filters the filters to add. + */ + public AndFilter(List filters) { + super(filters); + } + @Override public boolean accept(Stanza packet) { for (StanzaFilter filter : filters) {