All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.crabshue.commons.file.nio.FileRetrievalPredicates Maven / Gradle / Ivy

There is a newer version: 1.1.0
Show newest version
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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy