id

open fun id(): Long
open fun id(id: Long): EpoxyModel<T>

Override the default id in cases where the data subject naturally has an id, like an objectfrom a database. This id can only be set before the model is added to the adapter, it is anerror to change the id after that.

open fun id(@Nullable() ids: Array<Number>): EpoxyModel<T>

Use multiple numbers as the id for this model. Useful when you don't have a single long thatrepresents a unique id.

This hashes the numbers, so there is a tiny risk of collision with other ids.

open fun id(id1: Long, id2: Long): EpoxyModel<T>

Use two numbers as the id for this model. Useful when you don't have a single long thatrepresents a unique id.

This hashes the two numbers, so there is a tiny risk of collision with other ids.

open fun id(@Nullable() key: CharSequence): EpoxyModel<T>

Use a string as the model id. Useful for models that don't clearly map to a numerical id. Thisis preferable to using hashCode because that is a 32 bit hash and this is a 64bit hash, giving better spread and less chance of collision with other ids.

Since this uses a hashcode method to convert the String to a long there is a very small chancethat you may have a collision with another id. Assuming an even spread of hashcodes, andseveral hundred models in the adapter, there would be roughly 1 in 100 trillion chance of acollision. (http://preshing.com/20110504/hash-collision-probabilities/)

See also

com.airbnb.epoxy.IdUtils

IdUtils#hashString64Bit(CharSequence)

open fun id(@Nullable() key: CharSequence, @Nullable() otherKeys: Array<CharSequence>): EpoxyModel<T>

Use several strings to define the id of the model.

Similar to id, but with additional strings.

open fun id(@Nullable() key: CharSequence, id: Long): EpoxyModel<T>

Set an id that is namespaced with a string. This is useful when you need to show models ofmultiple types, side by side and don't want to risk id collisions.

Since this uses a hashcode method to convert the String to a long there is a very small chancethat you may have a collision with another id. Assuming an even spread of hashcodes, andseveral hundred models in the adapter, there would be roughly 1 in 100 trillion chance of acollision. (http://preshing.com/20110504/hash-collision-probabilities/)

See also

com.airbnb.epoxy.IdUtils

IdUtils#hashLong64Bit(long)