• 로그인 함 해보끄나?

  • Sarangnamu.net June 17, 2003
    Home Login Profile Study Open Project Q&A Google Code
    코틀린 Builder 패턴
    Last Modify : 07 June, 2017(05:41)
    https://stackoverflow.com/questions/36140791/how-to-implement-builder-pattern-in-kotlin class DialogParams constructor(val builder: DialogParams.Builder) { companion object { val ALERT = 0 val CONFIRM = 1 val LOADING = 2 } val type = builder.type val title = builder.title val message = builder.message val view = builder.view val listener = builder.listener class Builder { var type: Int = 0 private set var title: String? = null private set var message: String? = null private set var view: View? = null private set var listener: OnResultListener<DialogInterface>? = null private set fun type(type: Int) = apply { this.type = type } fun title(title: String) = apply { this.title = title } fun message(message: String) = apply { this.message = message } fun view(view: View) = apply { this.view = view } fun listener(listener: OnResultListener<DialogInterface>) = apply { this.listener = listener } fun build(): DialogParams { return DialogParams(this) } } }

    Comment


    입력하3 1498286971



    Locations of visitors to this page