[ 
https://issues.apache.org/jira/browse/IO-119?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12496391
 ] 

Niall Pemberton commented on IO-119:
------------------------------------

Answering in reverse - orBuilder() and andBuilder() are static convenience 
methods to create the initial builder.

    FileFilterBuilder builder = FileFilterBuilder.orBuilder()
is the same as
    FileFilterBuilder builder = new FileFilterBuilder(new OrFileFilter());


The problem is there is also a (non-static) or() method - so I couldn't name 
them the same - suggesstions welcome :)

On the end() method - its like adding a closing bracket (where and() or or() 
open them) - so if you wanted to do the following condition, using name() as an 
example:

  (A or (B and C) or (D and (E or F)))

you would do something like the following
    FileFilterBuilder builder = FileFilterBuilder.orBuilder()
        .name(A)
        .and().name(B).name(C).end()
        .and().name(D)
                  .or().name(E).name(F).endAll();

Its counter intuitive since usually the operators link conditions togther - 
whereas here they're defined at the start and everything that follows until an 
end(),  or()  or and() is joined with the same operator.

> Convenience "Builder" for creating complex FileFilter conditions
> ----------------------------------------------------------------
>
>                 Key: IO-119
>                 URL: https://issues.apache.org/jira/browse/IO-119
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Filters
>    Affects Versions: 1.3.1
>            Reporter: Niall Pemberton
>         Assigned To: Niall Pemberton
>            Priority: Minor
>             Fix For: 1.4
>
>         Attachments: FileFilterBuilder.java, FileFilterBuilderTestCase.java
>
>
> I'd like to add a new convenience "builder" class (FileFilterBuilder) to make 
> it easier to create complex FileFilter using Commons IO's IOFileFilter 
> implementations.
> Heres an example of how it can be used to create a IOFileFilter for the 
> following conditions:
>  - Either, directories which are not hidden and not named ".svn"
>  - or, files which have a suffix of ".java"
>     IOFileFilter filter = FileFilterBuilder.orBuilder()
>         .and().isDirectory().isHidden(false).not().name(".svn").end()
>         .and().isFile().suffix(".java").end()
>         .getFileFilter();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to