@@ -9,24 +9,30 @@ import android.widget.TextView
99import android.widget.Toast
1010import java.io.Serializable
1111
12- interface Text : Serializable {
12+ open class Text private constructor() : Serializable {
1313
14- fun isEmpty (): Boolean
15- fun getString (resources : Resources ): String?
14+ open fun isEmpty (): Boolean = true
15+ open fun getString (resources : Resources ): String? = null
1616
1717 companion object {
18+ @JvmStatic
19+ fun empty (): Text = Text ()
1820
21+ @JvmStatic
1922 fun from (string : String ): Text = StringText (string)
2023
24+ @JvmStatic
2125 fun from (@StringRes stringRes : Int ): Text = ResourceText (stringRes)
2226
27+ @JvmStatic
2328 fun from (@StringRes stringRes : Int , vararg formatArgs : Any ): Text =
2429 FormatResourceText (stringRes, * formatArgs)
2530
31+ @JvmStatic
2632 fun from (throwable : Throwable ): Text = StringText (throwable.message)
2733 }
2834
29- class StringText constructor(private val string : String? ) : Text {
35+ private class StringText internal constructor(private val string : String? ) : Text() {
3036
3137 override fun isEmpty (): Boolean = string.isNullOrEmpty()
3238
@@ -35,7 +41,7 @@ interface Text : Serializable {
3541 }
3642 }
3743
38- class ResourceText internal constructor(@StringRes private val stringRes : Int ) : Text {
44+ private class ResourceText internal constructor(@StringRes private val stringRes : Int ) : Text() {
3945
4046 override fun isEmpty (): Boolean = stringRes <= 0
4147
@@ -45,8 +51,8 @@ interface Text : Serializable {
4551
4652 }
4753
48- class FormatResourceText internal constructor(@StringRes private val stringRes : Int ,
49- private vararg val formatArgs : Any ) : Text {
54+ private class FormatResourceText internal constructor(@StringRes private val stringRes : Int ,
55+ private vararg val formatArgs : Any ) : Text() {
5056
5157 override fun isEmpty (): Boolean = stringRes <= 0
5258
0 commit comments