-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename @ArrayContentBased
to @Poko.ReadArrayContent
#449
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 2 additions & 3 deletions
5
poko-tests-without-k2/src/commonMain/kotlin/poko/AnyArrayHolder.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,11 +1,10 @@ | ||
package poko | ||
|
||
import dev.drewhamilton.poko.ArrayContentBased | ||
import dev.drewhamilton.poko.Poko | ||
|
||
@Suppress("Unused") | ||
@Poko class AnyArrayHolder( | ||
@ArrayContentBased val any: Any, | ||
@ArrayContentBased val nullableAny: Any?, | ||
@Poko.ReadArrayContent val any: Any, | ||
@Poko.ReadArrayContent val nullableAny: Any?, | ||
val trailingProperty: String, | ||
) |
41 changes: 20 additions & 21 deletions
41
poko-tests-without-k2/src/commonMain/kotlin/poko/ArrayHolder.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,27 @@ | ||
package poko | ||
|
||
import dev.drewhamilton.poko.ArrayContentBased | ||
import dev.drewhamilton.poko.Poko | ||
|
||
@Suppress("Unused") | ||
@Poko class ArrayHolder( | ||
@ArrayContentBased val stringArray: Array<String>, | ||
@ArrayContentBased val nullableStringArray: Array<String>?, | ||
@ArrayContentBased val booleanArray: BooleanArray, | ||
@ArrayContentBased val nullableBooleanArray: BooleanArray?, | ||
@ArrayContentBased val byteArray: ByteArray, | ||
@ArrayContentBased val nullableByteArray: ByteArray?, | ||
@ArrayContentBased val charArray: CharArray, | ||
@ArrayContentBased val nullableCharArray: CharArray?, | ||
@ArrayContentBased val shortArray: ShortArray, | ||
@ArrayContentBased val nullableShortArray: ShortArray?, | ||
@ArrayContentBased val intArray: IntArray, | ||
@ArrayContentBased val nullableIntArray: IntArray?, | ||
@ArrayContentBased val longArray: LongArray, | ||
@ArrayContentBased val nullableLongArray: LongArray?, | ||
@ArrayContentBased val floatArray: FloatArray, | ||
@ArrayContentBased val nullableFloatArray: FloatArray?, | ||
@ArrayContentBased val doubleArray: DoubleArray, | ||
@ArrayContentBased val nullableDoubleArray: DoubleArray?, | ||
@ArrayContentBased val nestedStringArray: Array<Array<String>>, | ||
@ArrayContentBased val nestedIntArray: Array<IntArray>, | ||
@Poko.ReadArrayContent val stringArray: Array<String>, | ||
@Poko.ReadArrayContent val nullableStringArray: Array<String>?, | ||
@Poko.ReadArrayContent val booleanArray: BooleanArray, | ||
@Poko.ReadArrayContent val nullableBooleanArray: BooleanArray?, | ||
@Poko.ReadArrayContent val byteArray: ByteArray, | ||
@Poko.ReadArrayContent val nullableByteArray: ByteArray?, | ||
@Poko.ReadArrayContent val charArray: CharArray, | ||
@Poko.ReadArrayContent val nullableCharArray: CharArray?, | ||
@Poko.ReadArrayContent val shortArray: ShortArray, | ||
@Poko.ReadArrayContent val nullableShortArray: ShortArray?, | ||
@Poko.ReadArrayContent val intArray: IntArray, | ||
@Poko.ReadArrayContent val nullableIntArray: IntArray?, | ||
@Poko.ReadArrayContent val longArray: LongArray, | ||
@Poko.ReadArrayContent val nullableLongArray: LongArray?, | ||
@Poko.ReadArrayContent val floatArray: FloatArray, | ||
@Poko.ReadArrayContent val nullableFloatArray: FloatArray?, | ||
@Poko.ReadArrayContent val doubleArray: DoubleArray, | ||
@Poko.ReadArrayContent val nullableDoubleArray: DoubleArray?, | ||
@Poko.ReadArrayContent val nestedStringArray: Array<Array<String>>, | ||
@Poko.ReadArrayContent val nestedIntArray: Array<IntArray>, | ||
) |
3 changes: 1 addition & 2 deletions
3
poko-tests-without-k2/src/commonMain/kotlin/poko/ComplexGenericArrayHolder.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,9 +1,8 @@ | ||
package poko | ||
|
||
import dev.drewhamilton.poko.ArrayContentBased | ||
import dev.drewhamilton.poko.Poko | ||
|
||
@Suppress("Unused") | ||
@Poko class ComplexGenericArrayHolder<A : Any, G : A>( | ||
@ArrayContentBased val generic: G, | ||
@Poko.ReadArrayContent val generic: G, | ||
) |
3 changes: 1 addition & 2 deletions
3
poko-tests-without-k2/src/commonMain/kotlin/poko/GenericArrayHolder.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,9 +1,8 @@ | ||
package poko | ||
|
||
import dev.drewhamilton.poko.ArrayContentBased | ||
import dev.drewhamilton.poko.Poko | ||
|
||
@Suppress("Unused") | ||
@Poko class GenericArrayHolder<G>( | ||
@ArrayContentBased val generic: G, | ||
@Poko.ReadArrayContent val generic: G, | ||
) |
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,11 +1,10 @@ | ||
package poko | ||
|
||
import dev.drewhamilton.poko.ArrayContentBased | ||
import dev.drewhamilton.poko.Poko | ||
|
||
@Suppress("Unused") | ||
@Poko class AnyArrayHolder( | ||
@ArrayContentBased val any: Any, | ||
@ArrayContentBased val nullableAny: Any?, | ||
@Poko.ReadArrayContent val any: Any, | ||
@Poko.ReadArrayContent val nullableAny: Any?, | ||
val trailingProperty: String, | ||
) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I correct that there is no binary compatibility concern here because this is a source-retention annotation?
In other words, an app with dependencies on two libraries each compiled with different Poko versions that both use this feature, won't care about the missing
dev.drewhamilton.poko.ArrayContentBased
type even if it's used to annotate one of the properties in one of the libraries?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep!