mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-19 10:32:05 +01:00
[core] Add AndFilter(List<StanzaFilter>) constructor
This commit is contained in:
parent
14142a0ef2
commit
61cb73ee37
2 changed files with 23 additions and 3 deletions
|
@ -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<StanzaFilter>(Arrays.asList(filters)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an filter using the specified filters.
|
||||
*
|
||||
* @param filters the filters to add.
|
||||
*/
|
||||
protected AbstractListFilter(List<StanzaFilter> 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<StanzaFilter>(Arrays.asList(filters));
|
||||
this.filters = filters;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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<StanzaFilter> filters) {
|
||||
super(filters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(Stanza packet) {
|
||||
for (StanzaFilter filter : filters) {
|
||||
|
|
Loading…
Reference in a new issue