Remove Decimal since it is quite specific, and has compile-time constraints
This commit is contained in:
parent
4e2c28a1b2
commit
5ebc7008eb
@ -4,7 +4,7 @@ kotlin.code.style=official
|
|||||||
specifyKotlinAsDependency=false
|
specifyKotlinAsDependency=false
|
||||||
|
|
||||||
projectGroup=ru.dbotthepony.kommons
|
projectGroup=ru.dbotthepony.kommons
|
||||||
projectVersion=2.8.2
|
projectVersion=2.9.0
|
||||||
|
|
||||||
guavaDepVersion=33.0.0
|
guavaDepVersion=33.0.0
|
||||||
gsonDepVersion=2.8.9
|
gsonDepVersion=2.8.9
|
||||||
|
@ -7,7 +7,6 @@ import it.unimi.dsi.fastutil.objects.ObjectAVLTreeSet
|
|||||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
|
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
|
||||||
import ru.dbotthepony.kommons.collect.ListenableMap
|
import ru.dbotthepony.kommons.collect.ListenableMap
|
||||||
import ru.dbotthepony.kommons.collect.ListenableSet
|
import ru.dbotthepony.kommons.collect.ListenableSet
|
||||||
import ru.dbotthepony.kommons.math.Decimal
|
|
||||||
import ru.dbotthepony.kommons.util.Delegate
|
import ru.dbotthepony.kommons.util.Delegate
|
||||||
import ru.dbotthepony.kommons.util.DelegateGetter
|
import ru.dbotthepony.kommons.util.DelegateGetter
|
||||||
import ru.dbotthepony.kommons.util.DelegateSetter
|
import ru.dbotthepony.kommons.util.DelegateSetter
|
||||||
@ -502,11 +501,6 @@ class DelegateSyncher : Observer {
|
|||||||
return add(ListenableDelegate.maskSmart(value, getter, setter), UUIDValueCodec)
|
return add(ListenableDelegate.maskSmart(value, getter, setter), UUIDValueCodec)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmOverloads
|
|
||||||
fun decimal(value: Decimal = Decimal.ZERO, setter: DelegateSetter<Decimal> = DelegateSetter.passthrough(), getter: DelegateGetter<Decimal> = DelegateGetter.passthrough()): Slot<Decimal> {
|
|
||||||
return add(ListenableDelegate.maskSmart(value, getter, setter), DecimalValueCodec)
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun <E> set(codec: StreamCodec<E>, backing: MutableSet<E> = ObjectOpenHashSet()): SetSlot<E> {
|
fun <E> set(codec: StreamCodec<E>, backing: MutableSet<E> = ObjectOpenHashSet()): SetSlot<E> {
|
||||||
return add(ListenableSet(backing), codec)
|
return add(ListenableSet(backing), codec)
|
||||||
|
@ -2,7 +2,6 @@ package ru.dbotthepony.kommons.io
|
|||||||
|
|
||||||
import it.unimi.dsi.fastutil.bytes.ByteArrayList
|
import it.unimi.dsi.fastutil.bytes.ByteArrayList
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap
|
||||||
import ru.dbotthepony.kommons.math.Decimal
|
|
||||||
import ru.dbotthepony.kommons.util.KOptional
|
import ru.dbotthepony.kommons.util.KOptional
|
||||||
import java.io.DataInput
|
import java.io.DataInput
|
||||||
import java.io.EOFException
|
import java.io.EOFException
|
||||||
@ -290,14 +289,6 @@ fun InputStream.readUUID(): UUID {
|
|||||||
return UUID(readLong(), readLong())
|
return UUID(readLong(), readLong())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun InputStream.readDecimal(): Decimal {
|
|
||||||
val size = readVarInt()
|
|
||||||
require(size >= 0) { "Negative payload size: $size" }
|
|
||||||
val bytes = ByteArray(size)
|
|
||||||
read(bytes)
|
|
||||||
return Decimal.fromByteArray(bytes)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun <S : InputStream, M : MutableMap<K, V>, K, V> S.readMap(keyReader: S.() -> K, valueReader: S.() -> V, constructor: (Int) -> M): M {
|
fun <S : InputStream, M : MutableMap<K, V>, K, V> S.readMap(keyReader: S.() -> K, valueReader: S.() -> V, constructor: (Int) -> M): M {
|
||||||
val size = readVarInt()
|
val size = readVarInt()
|
||||||
require(size >= 0) { "Negative payload size: $size" }
|
require(size >= 0) { "Negative payload size: $size" }
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package ru.dbotthepony.kommons.io
|
package ru.dbotthepony.kommons.io
|
||||||
|
|
||||||
import ru.dbotthepony.kommons.math.Decimal
|
|
||||||
import ru.dbotthepony.kommons.util.IStruct2b
|
import ru.dbotthepony.kommons.util.IStruct2b
|
||||||
import ru.dbotthepony.kommons.util.IStruct2d
|
import ru.dbotthepony.kommons.util.IStruct2d
|
||||||
import ru.dbotthepony.kommons.util.IStruct2f
|
import ru.dbotthepony.kommons.util.IStruct2f
|
||||||
@ -287,12 +286,6 @@ fun OutputStream.writeStruct4b(value: IStruct4b) {
|
|||||||
writeShort(value.component4().toInt() and 0xFF)
|
writeShort(value.component4().toInt() and 0xFF)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun OutputStream.writeDecimal(value: Decimal) {
|
|
||||||
val bytes = value.toByteArray()
|
|
||||||
writeVarInt(bytes.size)
|
|
||||||
write(bytes)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun <S : OutputStream, K, V> S.writeMap(map: Map<K, V>, keyWriter: S.(K) -> Unit, valueWriter: S.(V) -> Unit) {
|
fun <S : OutputStream, K, V> S.writeMap(map: Map<K, V>, keyWriter: S.(K) -> Unit, valueWriter: S.(V) -> Unit) {
|
||||||
writeVarInt(map.size)
|
writeVarInt(map.size)
|
||||||
|
|
||||||
|
@ -194,7 +194,6 @@ val UUIDValueCodec = StreamCodec.Impl({ s -> UUID(s.readLong(), s.readLong()) },
|
|||||||
val VarIntValueCodec = StreamCodec.Impl(DataInputStream::readSignedVarInt, DataOutputStream::writeSignedVarInt)
|
val VarIntValueCodec = StreamCodec.Impl(DataInputStream::readSignedVarInt, DataOutputStream::writeSignedVarInt)
|
||||||
val VarLongValueCodec = StreamCodec.Impl(DataInputStream::readSignedVarLong, DataOutputStream::writeSignedVarLong)
|
val VarLongValueCodec = StreamCodec.Impl(DataInputStream::readSignedVarLong, DataOutputStream::writeSignedVarLong)
|
||||||
val BinaryStringCodec = StreamCodec.Impl(DataInputStream::readBinaryString, DataOutputStream::writeBinaryString)
|
val BinaryStringCodec = StreamCodec.Impl(DataInputStream::readBinaryString, DataOutputStream::writeBinaryString)
|
||||||
val DecimalValueCodec = StreamCodec.Impl(DataInputStream::readDecimal, DataOutputStream::writeDecimal)
|
|
||||||
|
|
||||||
val OptionalBooleanValueCodec = StreamCodec.Optional(BooleanValueCodec)
|
val OptionalBooleanValueCodec = StreamCodec.Optional(BooleanValueCodec)
|
||||||
val OptionalByteValueCodec = StreamCodec.Optional(ByteValueCodec)
|
val OptionalByteValueCodec = StreamCodec.Optional(ByteValueCodec)
|
||||||
@ -209,7 +208,6 @@ val OptionalUUIDValueCodec = StreamCodec.Optional(UUIDValueCodec)
|
|||||||
val OptionalVarIntValueCodec = StreamCodec.Optional(VarIntValueCodec)
|
val OptionalVarIntValueCodec = StreamCodec.Optional(VarIntValueCodec)
|
||||||
val OptionalVarLongValueCodec = StreamCodec.Optional(VarLongValueCodec)
|
val OptionalVarLongValueCodec = StreamCodec.Optional(VarLongValueCodec)
|
||||||
val OptionalBinaryStringCodec = StreamCodec.Optional(BinaryStringCodec)
|
val OptionalBinaryStringCodec = StreamCodec.Optional(BinaryStringCodec)
|
||||||
val OptionalDecimalValueCodec = StreamCodec.Optional(DecimalValueCodec)
|
|
||||||
|
|
||||||
val KOptionalBooleanValueCodec = StreamCodec.KOptional(BooleanValueCodec)
|
val KOptionalBooleanValueCodec = StreamCodec.KOptional(BooleanValueCodec)
|
||||||
val KOptionalByteValueCodec = StreamCodec.KOptional(ByteValueCodec)
|
val KOptionalByteValueCodec = StreamCodec.KOptional(ByteValueCodec)
|
||||||
@ -224,7 +222,6 @@ val KOptionalUUIDValueCodec = StreamCodec.KOptional(UUIDValueCodec)
|
|||||||
val KOptionalVarIntValueCodec = StreamCodec.KOptional(VarIntValueCodec)
|
val KOptionalVarIntValueCodec = StreamCodec.KOptional(VarIntValueCodec)
|
||||||
val KOptionalVarLongValueCodec = StreamCodec.KOptional(VarLongValueCodec)
|
val KOptionalVarLongValueCodec = StreamCodec.KOptional(VarLongValueCodec)
|
||||||
val KOptionalBinaryStringCodec = StreamCodec.KOptional(BinaryStringCodec)
|
val KOptionalBinaryStringCodec = StreamCodec.KOptional(BinaryStringCodec)
|
||||||
val KOptionalDecimalValueCodec = StreamCodec.KOptional(DecimalValueCodec)
|
|
||||||
|
|
||||||
fun <E : Enum<E>> Class<E>.codec() = StreamCodec.Enum(this)
|
fun <E : Enum<E>> Class<E>.codec() = StreamCodec.Enum(this)
|
||||||
fun <E : Enum<E>> KClass<E>.codec() = StreamCodec.Enum(this.java)
|
fun <E : Enum<E>> KClass<E>.codec() = StreamCodec.Enum(this.java)
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user