Class FileFilterBuilder


  • public abstract class FileFilterBuilder
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DEFAULT_FILE_FILTER_IMP  
      protected static java.util.Map<java.lang.Class,​java.util.function.Function<java.lang.String,​java.lang.Object>> SUPPORTED_CNST_ARGS  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.io.FileFilter build​(java.lang.String filterExpression, java.lang.String filterImpl)
      Build a file filter implementation based on the parameters
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_FILE_FILTER_IMP

        public static final java.lang.String DEFAULT_FILE_FILTER_IMP
      • SUPPORTED_CNST_ARGS

        protected static final java.util.Map<java.lang.Class,​java.util.function.Function<java.lang.String,​java.lang.Object>> SUPPORTED_CNST_ARGS
    • Constructor Detail

      • FileFilterBuilder

        public FileFilterBuilder()
    • Method Detail

      • build

        public static java.io.FileFilter build​(java.lang.String filterExpression,
                                               java.lang.String filterImpl)
        Build a file filter implementation based on the parameters

        • If filterExpression is empty and filterImpl is the default '' then a functional filter that accepts all inputs is returned
        • If filterExpression is empty and filterImpl is not the default, then we attempt to use the default no-args constructor using Class.forName(filterImpl).newInstance(). If there isn't an accessible no-args constructor, then a RuntimeException is thrown.
        • If filterExpression is not empty, then we attempt to convert the the filterExpression into something that is supported by the declared constructors from the class. If conversion fails, then a RuntimeException will be thrown.
        • If filterImpl is empty, then a RuntimeException exception is thrown
        Parameters:
        filterExpression - the filter expression suitable for the implementation in question
        filterImpl - the class implementing FileFilter.
        Returns:
        a FileFilter implementation (hopefully never null).