guys following question, I have this class ``` @Pa...
# announcements
m
guys following question, I have this class
Copy code
@Parcelize
data class LikeAdStatesHolder(val askLogin : LikeAdState.AskLogin? = null,
                              val loadList : LikeAdState.LoadingList? = null,
                              val askWhichList: LikeAdState.AskWhichList? = null,
                              val liking : LikeAdState.Liking? = null) : Parcelable {
    enum class EntryPoint{
        ONE, TWO, THREE, FOUR;
    }

    fun entryPoint() : EntryPoint {
        return if(askWhichList != null && liking != null) {
            EntryPoint.FOUR
        } else if(askWhichList != null) {
            EntryPoint.THREE
        } else if(loadList != null) {
            EntryPoint.TWO
        } else if(askLogin != null) {
            EntryPoint.ONE
        } else {
            throw IllegalStateException("This RestoreHolder is not valid. ${toString()}")
        }
    }
}
I would like to define a contract for the method
entryPoint()
that if the method returns a value, the compiler should know that the associated values are not null, so I dont have to use the double explanation marks here:
Copy code
when (holder.entryPoint()) {
                    LikeAdStatesHolder.EntryPoint.ONE -> askLogin()
                    LikeAdStatesHolder.EntryPoint.TWO -> loadList()
                    LikeAdStatesHolder.EntryPoint.THREE -> askWhichList(holder.askWhichList!!.list)
                    LikeAdStatesHolder.EntryPoint.FOUR -> likeList(holder.liking!!.index, holder.askWhichList!!.list)
                }