public final Folder findTargetFolder ( @ NotNull final String generatorName , @ NotNull final String artifactName , final String targetPath ) throws ProjectNameNotDefinedException , ArtifactNotFoundException , FolderNameNotDefinedException , GeneratorNotFoundException , ProjectNotFoundException , FolderNotFoundException { Contract . requireArgNotNull ( "generatorName" , generatorName ) ; Contract . requireArgNotNull ( "artifactName" , artifactName ) ; final GeneratorConfig generator = generators . findByName ( generatorName ) ; int idx = generator . getArtifacts ( ) . indexOf ( new Artifact ( artifactName ) ) ; if ( idx < 0 ) { throw new ArtifactNotFoundException ( generatorName , artifactName ) ; } final Artifact artifact = generator . getArtifacts ( ) . get ( idx ) ; final String projectName ; final String folderName ; final String targetPattern ; final Target target = artifact . findTargetFor ( targetPath ) ; if ( target == null ) { projectName = artifact . getDefProject ( ) ; folderName = artifact . getDefFolder ( ) ; targetPattern = null ; } else { projectName = target . getDefProject ( ) ; folderName = target . getDefFolder ( ) ; targetPattern = target . getPattern ( ) ; } if ( projectName == null ) { throw new ProjectNameNotDefinedException ( generatorName , artifactName , targetPattern ) ; } if ( folderName == null ) { throw new FolderNameNotDefinedException ( generatorName , artifactName , targetPattern ) ; } idx = projects . indexOf ( new Project ( projectName , "dummy" ) ) ; if ( idx < 0 ) { throw new ProjectNotFoundException ( generatorName , artifactName , targetPattern , projectName ) ; } final Project project = projects . get ( idx ) ; idx = project . getFolders ( ) . indexOf ( new Folder ( folderName , "NotUsed" ) ) ; if ( idx < 0 ) { throw new FolderNotFoundException ( generatorName , artifactName , targetPattern , projectName , folderName ) ; } return project . getFolders ( ) . get ( idx ) ; }
Returns a target directory for a given combination of generator name artifact name and target sub path .