Gitlab service upgraded. Please report any problems to dl_gitadmin@cs.lth.se

Commit 6186feb3 authored by Noric Couderc's avatar Noric Couderc

Made the generation of apps generic

Loading applications from traces finds the application to generate based on the
type of the values and generates the appropriate type of application.
parent 1daebffc
......@@ -4,6 +4,7 @@ import org.apache.commons.csv.CSVFormat
import org.apache.commons.csv.CSVParser
import org.apache.commons.lang3.tuple.ImmutablePair
import java.io.StringReader
import java.lang.IllegalArgumentException
import java.util.ArrayList
import java.util.stream.Collectors
......@@ -24,8 +25,21 @@ class TraceLoader {
.map { r -> r[2].replace("\"", "") }
.map { r -> matchFunction(r) }
.collect(Collectors.toList<String>())
// TODO: Make this generic!
val app = ListApplication(methods, initClass.newInstance() as List<Int>)
val interfaceName = initClass.interfaces.map { it.name }
.filter { "java.util.Set" == it || "java.util.Map" == it || "java.util.List" == it }
.first()
.removePrefix("java.util.")
val app = when (interfaceName) {
"Set" -> SetApplication(methods, initClass.newInstance() as Set<Int>)
"Map" -> MapApplication(methods, initClass.newInstance() as Map<Int, Int>)
"List" -> ListApplication(methods, initClass.newInstance() as List<Int>)
else -> throw IllegalArgumentException(
String.format("The class '%s' is not supported by the current generator",
initClass.name)
)
}
apps.add(app)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment