package org.jivesoftware.smack.filter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.jivesoftware.smack.util.Objects;

public abstract class AbstractListFilter implements StanzaFilter {
   protected final List<StanzaFilter> filters;

   protected AbstractListFilter() {
      this.filters = new ArrayList();
   }

   protected AbstractListFilter(StanzaFilter... filters) {
      Objects.requireNonNull(filters, "Parameter must not be null.");
      StanzaFilter[] arr$ = filters;
      int len$ = filters.length;

      for(int i$ = 0; i$ < len$; ++i$) {
         StanzaFilter filter = arr$[i$];
         Objects.requireNonNull(filter, "Parameter must not be null.");
      }

      this.filters = new ArrayList(Arrays.asList(filters));
   }

   public void addFilter(StanzaFilter filter) {
      Objects.requireNonNull(filter, "Parameter must not be null.");
      this.filters.add(filter);
   }

   public final String toString() {
      StringBuilder sb = new StringBuilder();
      sb.append(this.getClass().getSimpleName());
      sb.append(": (");
      Iterator it = this.filters.iterator();

      while(it.hasNext()) {
         StanzaFilter filter = (StanzaFilter)it.next();
         sb.append(filter.toString());
         if (it.hasNext()) {
            sb.append(", ");
         }
      }

      sb.append(")");
      return sb.toString();
   }
}
