Merge pull request #51 from mipt-npm/dev
0.1.8-dev-4
This commit is contained in:
commit
f5b2b4c9e4
@ -7,7 +7,7 @@ plugins {
|
|||||||
id("org.jetbrains.dokka") version "0.10.1"
|
id("org.jetbrains.dokka") version "0.10.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
val dataforgeVersion by extra("0.1.8-dev-2")
|
val dataforgeVersion by extra("0.1.8-dev-4")
|
||||||
|
|
||||||
val bintrayRepo by extra("dataforge")
|
val bintrayRepo by extra("dataforge")
|
||||||
val githubProject by extra("dataforge-core")
|
val githubProject by extra("dataforge-core")
|
||||||
|
@ -16,8 +16,12 @@ import kotlinx.serialization.*
|
|||||||
@Serializable
|
@Serializable
|
||||||
sealed class MetaItem<out M : Meta> {
|
sealed class MetaItem<out M : Meta> {
|
||||||
|
|
||||||
|
abstract override fun equals(other: Any?): Boolean
|
||||||
|
|
||||||
|
abstract override fun hashCode(): Int
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class ValueItem(val value: Value) : MetaItem<Nothing>() {
|
class ValueItem(val value: Value) : MetaItem<Nothing>() {
|
||||||
override fun toString(): String = value.toString()
|
override fun toString(): String = value.toString()
|
||||||
|
|
||||||
@Serializer(ValueItem::class)
|
@Serializer(ValueItem::class)
|
||||||
@ -30,10 +34,18 @@ sealed class MetaItem<out M : Meta> {
|
|||||||
ValueSerializer.serialize(encoder, value.value)
|
ValueSerializer.serialize(encoder, value.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
return this.value == (other as? ValueItem)?.value
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
return value.hashCode()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class NodeItem<M : Meta>(@Serializable(MetaSerializer::class) val node: M) : MetaItem<M>() {
|
class NodeItem<M : Meta>(@Serializable(MetaSerializer::class) val node: M) : MetaItem<M>() {
|
||||||
//Fixing serializer for node could cause class cast problems, but it should not since Meta descendants are not serializeable
|
//Fixing serializer for node could cause class cast problems, but it should not since Meta descendants are not serializeable
|
||||||
override fun toString(): String = node.toString()
|
override fun toString(): String = node.toString()
|
||||||
|
|
||||||
@ -47,6 +59,10 @@ sealed class MetaItem<out M : Meta> {
|
|||||||
MetaSerializer.serialize(encoder, value.node)
|
MetaSerializer.serialize(encoder, value.node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean = node == (other as? NodeItem<*>)?.node
|
||||||
|
|
||||||
|
override fun hashCode(): Int = node.hashCode()
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -4,7 +4,7 @@ package hep.dataforge.meta.descriptors
|
|||||||
* An object which provides its descriptor
|
* An object which provides its descriptor
|
||||||
*/
|
*/
|
||||||
interface Described {
|
interface Described {
|
||||||
val descriptor: NodeDescriptor?
|
val descriptor: ItemDescriptor?
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val DESCRIPTOR_NODE = "@descriptor"
|
const val DESCRIPTOR_NODE = "@descriptor"
|
||||||
|
@ -9,13 +9,18 @@ import hep.dataforge.values.*
|
|||||||
/**
|
/**
|
||||||
* A converter of generic object to and from [MetaItem]
|
* A converter of generic object to and from [MetaItem]
|
||||||
*/
|
*/
|
||||||
interface MetaCaster<T : Any> {
|
interface MetaConverter<T : Any> {
|
||||||
fun itemToObject(item: MetaItem<*>): T
|
fun itemToObject(item: MetaItem<*>): T
|
||||||
fun objectToMetaItem(obj: T): MetaItem<*>
|
fun objectToMetaItem(obj: T): MetaItem<*>
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
val meta = object : MetaCaster<Meta> {
|
val item = object :MetaConverter<MetaItem<*>>{
|
||||||
|
override fun itemToObject(item: MetaItem<*>): MetaItem<*> = item
|
||||||
|
override fun objectToMetaItem(obj: MetaItem<*>): MetaItem<*> = obj
|
||||||
|
}
|
||||||
|
|
||||||
|
val meta = object : MetaConverter<Meta> {
|
||||||
override fun itemToObject(item: MetaItem<*>): Meta = when (item) {
|
override fun itemToObject(item: MetaItem<*>): Meta = when (item) {
|
||||||
is MetaItem.NodeItem -> item.node
|
is MetaItem.NodeItem -> item.node
|
||||||
is MetaItem.ValueItem -> item.value.toMeta()
|
is MetaItem.ValueItem -> item.value.toMeta()
|
||||||
@ -24,7 +29,7 @@ interface MetaCaster<T : Any> {
|
|||||||
override fun objectToMetaItem(obj: Meta): MetaItem<*> = MetaItem.NodeItem(obj)
|
override fun objectToMetaItem(obj: Meta): MetaItem<*> = MetaItem.NodeItem(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
val value = object : MetaCaster<Value> {
|
val value = object : MetaConverter<Value> {
|
||||||
override fun itemToObject(item: MetaItem<*>): Value = when (item) {
|
override fun itemToObject(item: MetaItem<*>): Value = when (item) {
|
||||||
is MetaItem.NodeItem -> item.node[Meta.VALUE_KEY].value ?: error("Can't convert node to a value")
|
is MetaItem.NodeItem -> item.node[Meta.VALUE_KEY].value ?: error("Can't convert node to a value")
|
||||||
is MetaItem.ValueItem -> item.value
|
is MetaItem.ValueItem -> item.value
|
||||||
@ -33,7 +38,7 @@ interface MetaCaster<T : Any> {
|
|||||||
override fun objectToMetaItem(obj: Value): MetaItem<*> = MetaItem.ValueItem(obj)
|
override fun objectToMetaItem(obj: Value): MetaItem<*> = MetaItem.ValueItem(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
val string = object : MetaCaster<String> {
|
val string = object : MetaConverter<String> {
|
||||||
override fun itemToObject(item: MetaItem<*>): String = when (item) {
|
override fun itemToObject(item: MetaItem<*>): String = when (item) {
|
||||||
is MetaItem.NodeItem -> item.node[Meta.VALUE_KEY].value ?: error("Can't convert node to a value")
|
is MetaItem.NodeItem -> item.node[Meta.VALUE_KEY].value ?: error("Can't convert node to a value")
|
||||||
is MetaItem.ValueItem -> item.value
|
is MetaItem.ValueItem -> item.value
|
||||||
@ -42,7 +47,7 @@ interface MetaCaster<T : Any> {
|
|||||||
override fun objectToMetaItem(obj: String): MetaItem<*> = MetaItem.ValueItem(obj.asValue())
|
override fun objectToMetaItem(obj: String): MetaItem<*> = MetaItem.ValueItem(obj.asValue())
|
||||||
}
|
}
|
||||||
|
|
||||||
val boolean = object : MetaCaster<Boolean> {
|
val boolean = object : MetaConverter<Boolean> {
|
||||||
override fun itemToObject(item: MetaItem<*>): Boolean = when (item) {
|
override fun itemToObject(item: MetaItem<*>): Boolean = when (item) {
|
||||||
is MetaItem.NodeItem -> item.node[Meta.VALUE_KEY].value ?: error("Can't convert node to a value")
|
is MetaItem.NodeItem -> item.node[Meta.VALUE_KEY].value ?: error("Can't convert node to a value")
|
||||||
is MetaItem.ValueItem -> item.value
|
is MetaItem.ValueItem -> item.value
|
||||||
@ -51,7 +56,7 @@ interface MetaCaster<T : Any> {
|
|||||||
override fun objectToMetaItem(obj: Boolean): MetaItem<*> = MetaItem.ValueItem(obj.asValue())
|
override fun objectToMetaItem(obj: Boolean): MetaItem<*> = MetaItem.ValueItem(obj.asValue())
|
||||||
}
|
}
|
||||||
|
|
||||||
val double = object : MetaCaster<Double> {
|
val double = object : MetaConverter<Double> {
|
||||||
override fun itemToObject(item: MetaItem<*>): Double = when (item) {
|
override fun itemToObject(item: MetaItem<*>): Double = when (item) {
|
||||||
is MetaItem.NodeItem -> item.node[Meta.VALUE_KEY].value ?: error("Can't convert node to a value")
|
is MetaItem.NodeItem -> item.node[Meta.VALUE_KEY].value ?: error("Can't convert node to a value")
|
||||||
is MetaItem.ValueItem -> item.value
|
is MetaItem.ValueItem -> item.value
|
||||||
@ -60,7 +65,7 @@ interface MetaCaster<T : Any> {
|
|||||||
override fun objectToMetaItem(obj: Double): MetaItem<*> = MetaItem.ValueItem(obj.asValue())
|
override fun objectToMetaItem(obj: Double): MetaItem<*> = MetaItem.ValueItem(obj.asValue())
|
||||||
}
|
}
|
||||||
|
|
||||||
val int = object : MetaCaster<Int> {
|
val int = object : MetaConverter<Int> {
|
||||||
override fun itemToObject(item: MetaItem<*>): Int = when (item) {
|
override fun itemToObject(item: MetaItem<*>): Int = when (item) {
|
||||||
is MetaItem.NodeItem -> item.node[Meta.VALUE_KEY].value ?: error("Can't convert node to a value")
|
is MetaItem.NodeItem -> item.node[Meta.VALUE_KEY].value ?: error("Can't convert node to a value")
|
||||||
is MetaItem.ValueItem -> item.value
|
is MetaItem.ValueItem -> item.value
|
||||||
@ -71,5 +76,5 @@ interface MetaCaster<T : Any> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T : Any> MetaCaster<T>.metaToObject(meta: Meta): T = itemToObject(MetaItem.NodeItem(meta))
|
fun <T : Any> MetaConverter<T>.metaToObject(meta: Meta): T = itemToObject(MetaItem.NodeItem(meta))
|
||||||
fun <T : Any> MetaCaster<T>.valueToObject(value: Value): T = itemToObject(MetaItem.ValueItem(value))
|
fun <T : Any> MetaConverter<T>.valueToObject(value: Value): T = itemToObject(MetaItem.ValueItem(value))
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
2
gradlew
vendored
2
gradlew
vendored
@ -82,6 +82,7 @@ esac
|
|||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
@ -129,6 +130,7 @@ fi
|
|||||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
1
gradlew.bat
vendored
1
gradlew.bat
vendored
@ -84,6 +84,7 @@ set CMD_LINE_ARGS=%*
|
|||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user