-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace ArrayContentBased with Poko.ReadArrayContent
This allows support for using this feature with a custom Poko annotation. Change ArrayContentBased to a deprecated typealias for compatibility.
- Loading branch information
1 parent
1838bd6
commit d8c58b5
Showing
8 changed files
with
60 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 6 additions & 24 deletions
30
poko-annotations/src/commonMain/kotlin/dev/drewhamilton/poko/ArrayContentBased.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,10 @@ | ||
package dev.drewhamilton.poko | ||
|
||
/** | ||
* Declares that a [Poko] class's generated functions will be based on this property's array | ||
* content. This differs from the Poko class (and data class) default of comparing arrays by | ||
* reference only. | ||
* | ||
* Poko class properties of type [Array], [BooleanArray], [CharArray], [ByteArray], [ShortArray], | ||
* [IntArray], [LongArray], [FloatArray], and [DoubleArray] are supported, including nested | ||
* [Array] types. | ||
* | ||
* Properties of a generic type or of type [Any] are also supported. For these properties, Poko will | ||
* generate a `when` statement that disambiguates the various array types at runtime and analyzes | ||
* content if the property is an array. (Note that with this logic, typed arrays will never be | ||
* considered equals to primitive arrays, even if they hold the same content. For example, | ||
* `arrayOf(1, 2)` will not be considered equals to `intArrayOf(1, 2)`.) | ||
* | ||
* Properties of a value class type that wraps an array are not supported. Tagging non-array | ||
* properties with this annotation is an error. | ||
* | ||
* Using array properties in data models is not generally recommended, because they are mutable. | ||
* Mutating an array marked with this annotation will cause the parent Poko class to produce | ||
* different `equals` and `hashCode` results at different times. This annotation should only be used | ||
* by consumers for whom performant code is more important than safe code. | ||
* Legacy name for [Poko.ReadArrayContent]. | ||
*/ | ||
@Retention(AnnotationRetention.SOURCE) | ||
@Target(AnnotationTarget.PROPERTY) | ||
public annotation class ArrayContentBased | ||
@Deprecated( | ||
message = "Moved to @Poko.ReadArrayContent for compatibility with custom Poko annotation", | ||
replaceWith = ReplaceWith("Poko.ReadArrayContent"), | ||
) | ||
public typealias ArrayContentBased = Poko.ReadArrayContent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters