Compare commits

...

6 Commits

Author SHA1 Message Date
203a350650 Merge remote-tracking branch 'github/dev' into dev 2024-03-08 10:19:20 +03:00
b076a6573a Update versions 2024-03-08 10:18:32 +03:00
SPC-code
e7d8b94889
Update attributes-kt/src/commonMain/kotlin/space/kscience/attributes/SafeType.kt
Co-authored-by: Gleb Minaev <43728100+lounres@users.noreply.github.com>
2024-03-08 10:07:54 +03:00
5dea38eef8 Merge remote-tracking branch 'github/dev' into dev 2024-03-08 10:07:28 +03:00
SPC-code
dcf5b19d80
Update attributes-kt/src/commonMain/kotlin/space/kscience/attributes/Attributes.kt
Co-authored-by: Gleb Minaev <43728100+lounres@users.noreply.github.com>
2024-03-08 10:06:30 +03:00
11722db3c8 Add Attributes container equality 2024-03-08 10:04:37 +03:00
6 changed files with 26 additions and 9 deletions

View File

@ -14,12 +14,16 @@ public abstract interface class space/kscience/attributes/AttributeWithDefault :
public abstract interface class space/kscience/attributes/Attributes {
public static final field Companion Lspace/kscience/attributes/Attributes$Companion;
public abstract fun equals (Ljava/lang/Object;)Z
public fun get (Lspace/kscience/attributes/Attribute;)Ljava/lang/Object;
public abstract fun getContent ()Ljava/util/Map;
public fun getKeys ()Ljava/util/Set;
public abstract fun hashCode ()I
public abstract fun toString ()Ljava/lang/String;
}
public final class space/kscience/attributes/Attributes$Companion {
public final fun equals (Lspace/kscience/attributes/Attributes;Lspace/kscience/attributes/Attributes;)Z
public final fun getEMPTY ()Lspace/kscience/attributes/Attributes;
}
@ -27,11 +31,14 @@ public final class space/kscience/attributes/AttributesBuilder : space/kscience/
public fun <init> ()V
public final fun add (Lspace/kscience/attributes/SetAttribute;Ljava/lang/Object;)V
public final fun build ()Lspace/kscience/attributes/Attributes;
public fun equals (Ljava/lang/Object;)Z
public final fun from (Lspace/kscience/attributes/Attributes;)V
public fun getContent ()Ljava/util/Map;
public fun hashCode ()I
public final fun invoke (Lspace/kscience/attributes/Attribute;Ljava/lang/Object;)V
public final fun remove (Lspace/kscience/attributes/SetAttribute;Ljava/lang/Object;)V
public final fun set (Lspace/kscience/attributes/Attribute;Ljava/lang/Object;)V
public fun toString ()Ljava/lang/String;
}
public final class space/kscience/attributes/AttributesBuilderKt {

View File

@ -5,10 +5,8 @@
package space.kscience.attributes
import kotlin.jvm.JvmInline
/**
* A set of attributes. The implementation must guarantee that [content] keys correspond to its value types.
* A set of attributes. The implementation must guarantee that [content] keys correspond to their value types.
*/
public interface Attributes {
/**
@ -27,14 +25,22 @@ public interface Attributes {
@Suppress("UNCHECKED_CAST")
public operator fun <T> get(attribute: Attribute<T>): T? = content[attribute] as? T
override fun toString(): String
override fun equals(other: Any?): Boolean
override fun hashCode(): Int
public companion object {
public val EMPTY: Attributes = AttributesImpl(emptyMap())
public fun equals(a1: Attributes, a2: Attributes): Boolean =
a1.keys == a2.keys && a1.keys.all { a1[it] == a2[it] }
}
}
@JvmInline
internal value class AttributesImpl(override val content: Map<out Attribute<*>, Any?>) : Attributes {
internal class AttributesImpl(override val content: Map<out Attribute<*>, Any?>) : Attributes {
override fun toString(): String = "Attributes(value=${content.entries})"
override fun equals(other: Any?): Boolean = other is Attributes && Attributes.equals(this, other)
override fun hashCode(): Int = content.hashCode()
}
public fun Attributes.isEmpty(): Boolean = content.isEmpty()

View File

@ -16,6 +16,10 @@ public class AttributesBuilder<out O> internal constructor(
public constructor() : this(mutableMapOf())
override fun toString(): String = "Attributes(value=${content.entries})"
override fun equals(other: Any?): Boolean = other is Attributes && Attributes.equals(this, other)
override fun hashCode(): Int = content.hashCode()
override val content: Map<out Attribute<*>, Any?> get() = map
public operator fun <T> set(attribute: Attribute<T>, value: T?) {

View File

@ -11,7 +11,7 @@ import kotlin.reflect.KType
import kotlin.reflect.typeOf
/**
* Safe variant ok Kotlin [KType] that ensures that the type parameter is of the same type ask [kType]
* Safe variant ok Kotlin [KType] that ensures that the type parameter is of the same type as [kType]
*
* @param kType raw [KType]
*/

View File

@ -14,7 +14,7 @@ allprojects {
}
group = "space.kscience"
version = "0.4.0-RC2"
version = "0.4.0"
}
subprojects {
@ -69,4 +69,4 @@ ksciencePublish {
apiValidation.nonPublicMarkers.add("space.kscience.kmath.UnstableKMathAPI")
val multikVersion by extra("0.2.2")
val multikVersion by extra("0.2.3")

View File

@ -6,7 +6,7 @@
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0"
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
}
dependencyResolutionManagement {