Skip to content

Commit

Permalink
Reformatted
Browse files Browse the repository at this point in the history
  • Loading branch information
leventeBajczi committed Jul 24, 2023
1 parent a194028 commit 9720b00
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import java.util.*
class TestGson {

companion object {

private fun explArgAdapterHelper(): Type =
TypeToken.getParameterized(
TypeToken.get(ArgAdapterHelper::class.java).type,
Expand Down Expand Up @@ -100,8 +101,10 @@ class TestGson {
private fun getExplBuilder(gsonSuppl: () -> Gson): GsonBuilder {
val gsonBuilder = GsonBuilder()

gsonBuilder.registerTypeHierarchyAdapter(ARG::class.java, ArgAdapter( gsonSuppl, { ExplOrd.getInstance() }, { explArgAdapterHelper() }))
gsonBuilder.registerTypeHierarchyAdapter(Trace::class.java, TraceAdapter(gsonSuppl, { ExplState::class.java }, SimpleStmtAction::class.java))
gsonBuilder.registerTypeHierarchyAdapter(ARG::class.java,
ArgAdapter(gsonSuppl, { ExplOrd.getInstance() }, { explArgAdapterHelper() }))
gsonBuilder.registerTypeHierarchyAdapter(Trace::class.java,
TraceAdapter(gsonSuppl, { ExplState::class.java }, SimpleStmtAction::class.java))
gsonBuilder.registerTypeHierarchyAdapter(SafetyResult::class.java,
SafetyResultAdapter(gsonSuppl, { explArgHelper() }, { explTraceHelper() }))

Expand All @@ -111,8 +114,10 @@ class TestGson {
private fun getPredBuilder(gsonSuppl: () -> Gson): GsonBuilder {
val gsonBuilder = GsonBuilder()

gsonBuilder.registerTypeHierarchyAdapter(ARG::class.java, ArgAdapter( gsonSuppl, { PartialOrd<PredState>{ a, b -> true} }, { predArgAdapterHelper() }))
gsonBuilder.registerTypeHierarchyAdapter(Trace::class.java, TraceAdapter(gsonSuppl, { PredState::class.java }, SimpleStmtAction::class.java))
gsonBuilder.registerTypeHierarchyAdapter(ARG::class.java,
ArgAdapter(gsonSuppl, { PartialOrd<PredState> { a, b -> true } }, { predArgAdapterHelper() }))
gsonBuilder.registerTypeHierarchyAdapter(Trace::class.java,
TraceAdapter(gsonSuppl, { PredState::class.java }, SimpleStmtAction::class.java))
gsonBuilder.registerTypeHierarchyAdapter(SafetyResult::class.java,
SafetyResultAdapter(gsonSuppl, { predArgHelper() }, { predTraceHelper() }))

Expand Down Expand Up @@ -189,7 +194,8 @@ class TestGson {
gson = getGson(getExplBuilder { gson }) { gson }

val trace = Trace.of(
listOf(ExplState.of(ImmutableValuation.builder().put(x, Int(1)).build()), ExplState.of(ImmutableValuation.builder().put(x, Int(2)).build())),
listOf(ExplState.of(ImmutableValuation.builder().put(x, Int(1)).build()),
ExplState.of(ImmutableValuation.builder().put(x, Int(2)).build())),
listOf(SimpleStmtAction(SkipStmt.getInstance()))
)

Expand All @@ -215,13 +221,14 @@ class TestGson {
}


class SimpleStmtAction(val stmt: Stmt): StmtAction() {
class SimpleStmtAction(val stmt: Stmt) : StmtAction() {

override fun getStmts(): List<Stmt> {
return listOf(stmt);
}
}

class SimpleStmtActionAdapter(val gsonUtils: () -> Gson): TypeAdapter<SimpleStmtAction>() {
class SimpleStmtActionAdapter(val gsonUtils: () -> Gson) : TypeAdapter<SimpleStmtAction>() {

override fun write(out: JsonWriter, value: SimpleStmtAction) {
gsonUtils().toJson(gsonUtils().toJsonTree(value.stmt, Stmt::class.java), out)
Expand Down

0 comments on commit 9720b00

Please sign in to comment.