de.unkrig.commons.file.filetransformation
Class SelectiveFileTransformer

java.lang.Object
  extended by de.unkrig.commons.file.filetransformation.SelectiveFileTransformer
All Implemented Interfaces:
FileTransformer

public class SelectiveFileTransformer
extends java.lang.Object
implements FileTransformer

A FileTransformer that feeds the file to the trueDelegate iff the path matches a given Predicate, and otherwise to the falseDelegate.


Nested Class Summary
 
Nested classes/interfaces inherited from interface de.unkrig.commons.file.filetransformation.FileTransformer
FileTransformer.Mode
 
Field Summary
 
Fields inherited from interface de.unkrig.commons.file.filetransformation.FileTransformer
NOT_IDENTICAL, THROW_NOT_IDENTICAL
 
Constructor Summary
SelectiveFileTransformer(Predicate<java.lang.String> pathPredicate, FileTransformer trueDelegate, FileTransformer falseDelegate)
           
 
Method Summary
 java.lang.String toString()
           
 void transform(java.lang.String path, java.io.File in, java.io.File out, FileTransformer.Mode mode)
          Creates the file out, based on the file in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SelectiveFileTransformer

public SelectiveFileTransformer(Predicate<java.lang.String> pathPredicate,
                                FileTransformer trueDelegate,
                                FileTransformer falseDelegate)
Method Detail

transform

public void transform(java.lang.String path,
                      java.io.File in,
                      java.io.File out,
                      FileTransformer.Mode mode)
               throws java.io.IOException
Description copied from interface: FileTransformer
Creates the file out, based on the file in. Iff in.equals(out) ('in-place transformation'), then the original file remains unchanged, is modified, or replaced with a new file.

The precise contract is as follows:

Specified by:
transform in interface FileTransformer
Parameters:
path - A text designating the input file; typically, but not necessarily identical with in.getPath()
Throws:
java.io.IOException
See Also:
FileTransformer.NOT_IDENTICAL, FileTransformer.Mode.TRANSFORM, FileTransformer.Mode.CHECK, FileTransformer.Mode.CHECK_AND_TRANSFORM

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object