Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def line = "test (HttpServletRequest request,String sessionId,@RequestBody(required = false) @ApiParam(\"PlatformFilterPost payload for filter.\")PlatformFilterPost platformFilterPost, test) {";
- println(getMethodArguments(line))
- def getMethodArguments(methodLine) {
- def methodSignature = getMethodSignature(methodLine);
- if (methodSignature) {
- def methodArguments = getMethodSignatureArguments(methodSignature);
- if (methodArguments) {
- return methodArguments;
- }
- else {
- return null;
- }
- }
- else {
- return null;
- }
- }
- def getMethodSignature(methodLine) {
- return methodLine.find( /\(([\s\S]+?)\)(?=[^()]*(\}|\{|;))/ ) {
- it[1];
- };
- }
- def getMethodSignatureArguments(methodSignature) {
- def matcher = methodSignature =~ /((?:(\@\w+\(.*?\))\s*?)*?(?:\w+)(?:\s+)(\w+)(\,|\s)*?)+/;
- def args = []
- while(matcher.find()){
- args.add(matcher.group().replaceAll(/(.+\s+)/,"").trim())
- };
- return args;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement