Made config constructors private

This commit is contained in:
Erik C. Thauvin 2024-05-26 00:19:18 -07:00
parent b9449b9140
commit 30a3e9022d
Signed by: erik
GPG key ID: 776702A6A2DA330E
3 changed files with 30 additions and 48 deletions

View file

@ -40,23 +40,14 @@ import net.thauvin.erik.bitly.config.deeplinks.CreateDeeplinks
* See the [Bit.ly API](https://dev.bitly.com/api-reference#createFullBitlink) for more information.
*/
@Suppress("LocalVariableName", "PropertyName")
class CreateConfig @JvmOverloads constructor(
var long_url: String,
var domain: String = Constants.EMPTY,
var group_guid: String = Constants.EMPTY,
var title: String = Constants.EMPTY,
var tags: Array<String> = emptyArray(),
var deeplinks: CreateDeeplinks = CreateDeeplinks(),
var toJson: Boolean = false
) {
constructor(builder: Builder) : this(builder.long_url) {
domain = builder.domain
group_guid = builder.group_guid
title = builder.title
tags = builder.tags
deeplinks = builder.deeplinks
toJson = builder.toJson
}
class CreateConfig private constructor(builder: Builder) {
val long_url = builder.long_url
val domain = builder.domain
val group_guid = builder.group_guid
val title = builder.title
val tags = builder.tags
val deeplinks = builder.deeplinks
val toJson = builder.toJson
/**
* Configures the creation parameters of a Bitlink.

View file

@ -39,21 +39,13 @@ import net.thauvin.erik.bitly.config.deeplinks.UpdateDeeplinks
*
* See the [Bit.ly API](https://dev.bitly.com/api-reference#updateBitlink) for more information.
*/
class UpdateConfig @JvmOverloads constructor(
var bitlink: String,
var title: String = Constants.EMPTY,
var archived: Boolean = false,
var tags: Array<String> = emptyArray(),
var deeplinks: UpdateDeeplinks = UpdateDeeplinks(),
var toJson: Boolean = false
) {
constructor(builder: Builder) : this(builder.bitlink) {
title = builder.title
archived = builder.archived
tags = builder.tags
deeplinks = builder.deeplinks
toJson = builder.toJson
}
class UpdateConfig private constructor(builder: Builder) {
val bitlink = builder.bitlink
val title = builder.title
val archived = builder.archived
val tags = builder.tags
val deeplinks = builder.deeplinks
val toJson = builder.toJson
/**
* Configures the update parameters of a Bitlink.

View file

@ -34,9 +34,9 @@ package net.thauvin.erik.bitly.config
import assertk.assertThat
import assertk.assertions.isEqualTo
import net.thauvin.erik.bitly.config.deeplinks.CreateDeeplinks
import net.thauvin.erik.bitly.config.deeplinks.UpdateDeeplinks
import net.thauvin.erik.bitly.config.deeplinks.enums.InstallType
import net.thauvin.erik.bitly.config.deeplinks.enums.Os
import net.thauvin.erik.bitly.config.deeplinks.UpdateDeeplinks
import org.json.JSONObject
import kotlin.test.Test
@ -48,14 +48,13 @@ class ConfigTest {
install_type(InstallType.AUTO_INSTALL)
}
val config = CreateConfig(
"long_url",
"domain",
"group_guid",
"title",
arrayOf("tag", "tag2"),
deeplinks,
)
val config = CreateConfig.Builder("long_url")
.domain("domain")
.groupGuid("group_guid")
.title("title")
.tags(arrayOf("tag", "tag2"))
.deeplinks(deeplinks)
.build()
val map = mapOf(
"long_url" to config.long_url,
@ -81,13 +80,13 @@ class ConfigTest {
app_guid("app_guid")
}
val config = UpdateConfig(
"blink",
"title",
true,
arrayOf("tag", "tag2"),
deeplinks
)
val config = UpdateConfig.Builder("blink")
.title("title")
.archived(true)
.tags(arrayOf("tag", "tag2"))
.deeplinks(deeplinks)
.build()
val map = mapOf(
"bitlink" to config.bitlink,
"title" to config.title,