protected void validate ( File directory , ValidationOptions option ) { if ( ! directory . exists ( ) ) { this . errors . addError ( "directory <{}> does not exist in file system" , directory . getAbsolutePath ( ) ) ; } else if ( ! directory . isDirectory ( ) ) { this . errors . addError ( "directory <{}> is not a directory" , directory . getAbsolutePath ( ) ) ; } else if ( directory . isHidden ( ) ) { this . errors . addError ( "directory <{}> is a hidden directory" , directory . getAbsolutePath ( ) ) ; } else { switch ( option ) { case AS_SOURCE : if ( ! directory . canRead ( ) ) { this . errors . addError ( "directory <{}> is not readable" , directory . getAbsolutePath ( ) ) ; } break ; case AS_SOURCE_AND_TARGET : if ( ! directory . canRead ( ) ) { this . errors . addError ( "directory <{}> is not readable" , directory . getAbsolutePath ( ) ) ; } if ( ! directory . canWrite ( ) ) { this . errors . addError ( "directory <{}> is not writable" , directory . getAbsolutePath ( ) ) ; } break ; case AS_TARGET : if ( ! directory . canWrite ( ) ) { this . errors . addError ( "directory <{}> is not writable" , directory . getAbsolutePath ( ) ) ; } break ; } } }
Does the actual validation