Cleaned up config.

This commit is contained in:
Erik C. Thauvin 2024-05-25 22:15:39 -07:00
parent bfb7ebcc09
commit 414fbc07cb
Signed by: erik
GPG key ID: 776702A6A2DA330E
2 changed files with 19 additions and 20 deletions

View file

@ -35,17 +35,16 @@ import java.math.RoundingMode
/**
* Provides a configuration builder.
*/
class Config private constructor(builder: Builder) {
val text: String
val wpm: Int
val postfix: String
val plural: String
val excludeImages: Boolean
val extra: Int
val roundingMode: RoundingMode
init {
text = builder.text
class Config @JvmOverloads constructor(
val text: String,
var wpm: Int = 275,
var postfix: String = "min read",
var plural: String = "min read",
var excludeImages: Boolean = false,
var extra: Int = 0,
var roundingMode: RoundingMode = RoundingMode.HALF_EVEN
) {
constructor(builder: Builder) : this(builder.text) {
wpm = builder.wpm
postfix = builder.postfix
plural = builder.plural
@ -105,6 +104,6 @@ class Config private constructor(builder: Builder) {
/**
* Builds the configuration.
*/
fun build() = Config(this)
fun build(): Config = Config(this)
}
}

View file

@ -17,7 +17,7 @@
final Boolean excludeImages = (Boolean) getJspContext().getAttribute("excludeImages");
final Integer extra = (Integer) getJspContext().getAttribute("extra");
final Integer wpm = (Integer) getJspContext().getAttribute("wpm");
final String body = (String) getJspContext().getAttribute("body");;
final String body = (String) getJspContext().getAttribute("body");
final String plural = (String) getJspContext().getAttribute("plural");
final String postfix = (String) getJspContext().getAttribute("postfix");