com.crabshue.commons.file.nio.FileRetrievalPredicates Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-nio-file Show documentation
Show all versions of commons-nio-file Show documentation
Library for file system operations (using java.nio.file).
package com.crabshue.commons.file.nio;
import java.nio.file.Path;
import java.util.function.Predicate;
import org.apache.commons.lang3.StringUtils;
import lombok.NonNull;
/**
* Utility class dedicated to the creation of predicates to use in a file retrieval operation.
*/
public class FileRetrievalPredicates {
/**
* Predeciate for file retrieval based on the filename extension
*
* @param extension the extension
* @return the predicate.
*/
public static Predicate fileExtensionName(@NonNull final String extension) {
return file -> StringUtils.endsWith(file.getFileName().toString(), extension);
}
}