ru.vyarus.gradle.plugin.animalsniffer.util.ContainFilesSpec.groovy Maven / Gradle / Ivy
package ru.vyarus.gradle.plugin.animalsniffer.util
import org.gradle.api.specs.Spec
/**
* Matches only files from provided collection. Useful for exclude/include logic on file collection:
* fileCollection.filter new ContainFilesSpec(someFiles)
* to preserve only files containing in someFiles collection (include). And the opposite:
* fileCollection.filter new NotSpec(new ContainFilesSpec(someFiles))
* to exclude all files in someFiles collection (exclude).
*
* @author Vyacheslav Rusakov
* @since 24.05.2017
*/
class ContainFilesSpec implements Spec {
private final Set files
ContainFilesSpec(Set files) {
this.files = files
}
@Override
boolean isSatisfiedBy(File element) {
return files.contains(element)
}
}