Class SourceToObjectUtils
java.lang.Object
edu.university.ecs.lab.common.utils.SourceToObjectUtils
Static utility class for parsing a file and returning associated models from code structure.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Method
convertValidEndpoints
(String preURL, com.github.javaparser.ast.body.MethodDeclaration methodDeclaration, Method method) This method converts a valid Method to an Endpointstatic MethodCall
convertValidRestCalls
(com.github.javaparser.ast.expr.MethodCallExpr methodCallExpr, MethodCall methodCall) This method converts a valid MethodCall to an RestCallstatic JClass
parseClass
(File sourceFile, Config config) This method parses a Java class file and return a JClass object.static Set<MethodCall>
parseMethodCalls
(List<com.github.javaparser.ast.body.MethodDeclaration> methodDeclarations) This method parses methodDeclarations list and returns a Set of MethodCall modelsparseMethods
(String preURL, List<com.github.javaparser.ast.body.MethodDeclaration> methodDeclarations) This method parses methodDeclarations list and returns a Set of Method models
-
Constructor Details
-
SourceToObjectUtils
public SourceToObjectUtils()
-
-
Method Details
-
parseClass
This method parses a Java class file and return a JClass object.- Parameters:
sourceFile
- the file to parse- Returns:
- the JClass object representing the file
-
parseMethods
public static Set<Method> parseMethods(String preURL, List<com.github.javaparser.ast.body.MethodDeclaration> methodDeclarations) This method parses methodDeclarations list and returns a Set of Method models- Parameters:
preURL
- the preURLmethodDeclarations
- the list of methodDeclarations to be parsed- Returns:
- a set of Method models representing the MethodDeclarations
-
convertValidEndpoints
public static Method convertValidEndpoints(String preURL, com.github.javaparser.ast.body.MethodDeclaration methodDeclaration, Method method) This method converts a valid Method to an Endpoint- Parameters:
preURL
- the preURLmethodDeclaration
- the MethodDeclaration associated with Methodmethod
- the Method to be converted- Returns:
- returns method if it is invalid, otherwise a new Endpoint
-
parseMethodCalls
public static Set<MethodCall> parseMethodCalls(List<com.github.javaparser.ast.body.MethodDeclaration> methodDeclarations) This method parses methodDeclarations list and returns a Set of MethodCall models- Parameters:
methodDeclarations
- the list of methodDeclarations to be parsed- Returns:
- a set of MethodCall models representing MethodCallExpressions found in the MethodDeclarations
-
convertValidRestCalls
public static MethodCall convertValidRestCalls(com.github.javaparser.ast.expr.MethodCallExpr methodCallExpr, MethodCall methodCall) This method converts a valid MethodCall to an RestCall- Parameters:
methodCallExpr
- the MethodDeclaration associated with MethodmethodCall
- the MethodCall to be converted- Returns:
- returns methodCall if it is invalid, otherwise a new RestCall
-