public Set < ApiResourceMetadata > extractControllers ( JCodeModel bodyCodeModel , RamlRoot raml ) { Set < ApiResourceMetadata > controllers = new LinkedHashSet <> ( ) ; if ( raml == null ) { return controllers ; } if ( bodyCodeModel == null ) { bodyCodeModel = new JCodeModel ( ) ; } Set < String > names = new LinkedHashSet <> ( ) ; Set < String > namesToDisable = new LinkedHashSet <> ( ) ; // Iterate on all parent resources // if we have child resources, just append the url and go down the chain // until we hit the first action. // if an action is found we need to for ( Entry < String , RamlResource > resource : raml . getResources ( ) . entrySet ( ) ) { Set < ApiResourceMetadata > resources = checkResource ( bodyCodeModel , startUrl , resource . getValue ( ) , null , raml ) ; for ( ApiResourceMetadata resourceMetadata : resources ) { if ( names . contains ( resourceMetadata . getResourceName ( ) ) ) { // collision has occured, lets mark this for 2nd pass namesToDisable . add ( resourceMetadata . getResourceName ( ) ) ; } names . add ( resourceMetadata . getResourceName ( ) ) ; controllers . add ( resourceMetadata ) ; } } // second pass, disabling singularisation for ( ApiResourceMetadata resourceMetadata : controllers ) { if ( namesToDisable . contains ( resourceMetadata . getResourceName ( ) ) ) { resourceMetadata . setSingularizeName ( false ) ; } } return controllers ; }
This method will extract a set of controllers from the RAML file . These controllers will contain the metadata required by the code generator including name any annotations as well as conatining methods