Skip to content

Commit 1cc7ea1

Browse files
committed
Improves serialization of Title instances.
1 parent b3b0963 commit 1cc7ea1

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@ java {
1515
}
1616

1717
dokka {
18-
outputFormat = 'html'
18+
outputFormat = 'html-as-java'
1919
outputDirectory = "$buildDir/dokka"
2020
}
2121

2222
task javadocJar(type: Jar) {
2323
archiveClassifier = 'javadoc'
2424
dependsOn dokka
25-
from("$buildDir/dokka/isbd-parser")
26-
from("$buildDir/dokka/style.css")
25+
from("$buildDir/dokka/")
2726
}
2827

2928
publishing {
@@ -95,6 +94,7 @@ repositories {
9594

9695
dependencies {
9796
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
97+
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.12.1'
9898
api 'com.github.norswap:autumn:80abd5c207'
9999
testImplementation 'junit:junit:4.12'
100100
}

src/main/kotlin/ca/voidstarzero/isbd/titlestatement/TitleStatementParser.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class TitleStatementParser : TitleStatementGrammar() {
6262
return result.value_stack.mapNotNull { it as TitleStatement }
6363
}
6464

65-
throw Exception(result.toString())
65+
return emptyList()
6666
}
6767

6868
/** Produces all possible parses of the given title statement string.

src/main/kotlin/ca/voidstarzero/isbd/titlestatement/ast/Title.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
package ca.voidstarzero.isbd.titlestatement.ast
22

3+
import com.fasterxml.jackson.annotation.JsonTypeInfo
4+
35
/**
46
* Base class for titles.
57
*/
6-
sealed class Title() : Node() {}
8+
@JsonTypeInfo(
9+
use = JsonTypeInfo.Id.NAME,
10+
include = JsonTypeInfo.As.EXISTING_PROPERTY,
11+
property = "type"
12+
)
13+
sealed class Title() : Node() {
14+
val type = this::class.java.simpleName
15+
}
716

817
/**
918
* A class holding the title part of a title statement.

0 commit comments

Comments
 (0)