Made config constructors private
This commit is contained in:
parent
b9449b9140
commit
30a3e9022d
3 changed files with 30 additions and 48 deletions
|
@ -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.
|
* See the [Bit.ly API](https://dev.bitly.com/api-reference#createFullBitlink) for more information.
|
||||||
*/
|
*/
|
||||||
@Suppress("LocalVariableName", "PropertyName")
|
@Suppress("LocalVariableName", "PropertyName")
|
||||||
class CreateConfig @JvmOverloads constructor(
|
class CreateConfig private constructor(builder: Builder) {
|
||||||
var long_url: String,
|
val long_url = builder.long_url
|
||||||
var domain: String = Constants.EMPTY,
|
val domain = builder.domain
|
||||||
var group_guid: String = Constants.EMPTY,
|
val group_guid = builder.group_guid
|
||||||
var title: String = Constants.EMPTY,
|
val title = builder.title
|
||||||
var tags: Array<String> = emptyArray(),
|
val tags = builder.tags
|
||||||
var deeplinks: CreateDeeplinks = CreateDeeplinks(),
|
val deeplinks = builder.deeplinks
|
||||||
var toJson: Boolean = false
|
val toJson = builder.toJson
|
||||||
) {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the creation parameters of a Bitlink.
|
* Configures the creation parameters of a Bitlink.
|
||||||
|
|
|
@ -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.
|
* See the [Bit.ly API](https://dev.bitly.com/api-reference#updateBitlink) for more information.
|
||||||
*/
|
*/
|
||||||
class UpdateConfig @JvmOverloads constructor(
|
class UpdateConfig private constructor(builder: Builder) {
|
||||||
var bitlink: String,
|
val bitlink = builder.bitlink
|
||||||
var title: String = Constants.EMPTY,
|
val title = builder.title
|
||||||
var archived: Boolean = false,
|
val archived = builder.archived
|
||||||
var tags: Array<String> = emptyArray(),
|
val tags = builder.tags
|
||||||
var deeplinks: UpdateDeeplinks = UpdateDeeplinks(),
|
val deeplinks = builder.deeplinks
|
||||||
var toJson: Boolean = false
|
val toJson = builder.toJson
|
||||||
) {
|
|
||||||
constructor(builder: Builder) : this(builder.bitlink) {
|
|
||||||
title = builder.title
|
|
||||||
archived = builder.archived
|
|
||||||
tags = builder.tags
|
|
||||||
deeplinks = builder.deeplinks
|
|
||||||
toJson = builder.toJson
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the update parameters of a Bitlink.
|
* Configures the update parameters of a Bitlink.
|
||||||
|
|
|
@ -34,9 +34,9 @@ package net.thauvin.erik.bitly.config
|
||||||
import assertk.assertThat
|
import assertk.assertThat
|
||||||
import assertk.assertions.isEqualTo
|
import assertk.assertions.isEqualTo
|
||||||
import net.thauvin.erik.bitly.config.deeplinks.CreateDeeplinks
|
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.InstallType
|
||||||
import net.thauvin.erik.bitly.config.deeplinks.enums.Os
|
import net.thauvin.erik.bitly.config.deeplinks.enums.Os
|
||||||
import net.thauvin.erik.bitly.config.deeplinks.UpdateDeeplinks
|
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
|
|
||||||
|
@ -48,14 +48,13 @@ class ConfigTest {
|
||||||
install_type(InstallType.AUTO_INSTALL)
|
install_type(InstallType.AUTO_INSTALL)
|
||||||
}
|
}
|
||||||
|
|
||||||
val config = CreateConfig(
|
val config = CreateConfig.Builder("long_url")
|
||||||
"long_url",
|
.domain("domain")
|
||||||
"domain",
|
.groupGuid("group_guid")
|
||||||
"group_guid",
|
.title("title")
|
||||||
"title",
|
.tags(arrayOf("tag", "tag2"))
|
||||||
arrayOf("tag", "tag2"),
|
.deeplinks(deeplinks)
|
||||||
deeplinks,
|
.build()
|
||||||
)
|
|
||||||
|
|
||||||
val map = mapOf(
|
val map = mapOf(
|
||||||
"long_url" to config.long_url,
|
"long_url" to config.long_url,
|
||||||
|
@ -81,13 +80,13 @@ class ConfigTest {
|
||||||
app_guid("app_guid")
|
app_guid("app_guid")
|
||||||
}
|
}
|
||||||
|
|
||||||
val config = UpdateConfig(
|
val config = UpdateConfig.Builder("blink")
|
||||||
"blink",
|
.title("title")
|
||||||
"title",
|
.archived(true)
|
||||||
true,
|
.tags(arrayOf("tag", "tag2"))
|
||||||
arrayOf("tag", "tag2"),
|
.deeplinks(deeplinks)
|
||||||
deeplinks
|
.build()
|
||||||
)
|
|
||||||
val map = mapOf(
|
val map = mapOf(
|
||||||
"bitlink" to config.bitlink,
|
"bitlink" to config.bitlink,
|
||||||
"title" to config.title,
|
"title" to config.title,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue