package net.sf.jabref.gui.importer;

import java.io.File;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;

import net.sf.jabref.logic.importer.Importer;
import net.sf.jabref.logic.util.FileExtensions;

class ImportFileFilter extends FileFilter implements Comparable<ImportFileFilter> {
    private final String description;
    private final FileNameExtensionFilter fileFilter;

    public ImportFileFilter(Importer format) {
        FileExtensions extensions = format.getExtensions();
        this.description = extensions.getDescription();
        fileFilter = new FileNameExtensionFilter(extensions.getDescription(), extensions.getExtensions());
    }

    public ImportFileFilter(String description, Collection<Importer> formats) {
        this.description = description;

        List<FileExtensions> extensions = formats.stream().map(p -> p.getExtensions()).collect(Collectors.toList());
        List<String> flatExtensions = extensions.stream().flatMap(extList -> Stream.of(extList.getExtensions())).collect(Collectors.toList());
        fileFilter = new FileNameExtensionFilter(description, flatExtensions.toArray(new String[flatExtensions.size()]));
    }

    @Override
    public boolean accept(File file) {
        return (file != null) && (file.isDirectory() || fileFilter.accept(file));
    }

    @Override
    public String getDescription() {
        return description;
    }

    @Override
    public int compareTo(ImportFileFilter o) {
        return description.compareTo(o.description);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o instanceof ImportFileFilter) {
            return description.equals(((ImportFileFilter) o).description);
        }
        return false;
    }

    @Override
    public int hashCode() {
        return description.hashCode();
    }

}

@@ -51,16 +51,41 @@
 o.File;%0A
+import java.util.Arrays;%0A
 import j
@@ -105,16 +105,16 @@
 ection;%0A
-
 import j
@@ -167,40 +167,8 @@
 ors;
-%0Aimport java.util.stream.Stream;
 %0A%0Aim
@@ -444,16 +444,17 @@
 lter%3E %7B%0A
+%0A
     priv
@@ -935,17 +935,16 @@
 iption;%0A
-%0A
         
@@ -1133,17 +1133,21 @@
  -%3E 
-S
+Arrays.s
 tream
-.of
 (ext
@@ -1168,16 +1168,33 @@
 ions()))
+%0A                
 .collect
@@ -1277,16 +1277,32 @@
 ription,
+%0A               
  flatExt

Use Arrays.stream