mirror of
https://github.com/corda/corda.git
synced 2025-06-19 07:38:22 +00:00
Declare serialisation default interface methods as Java8-style defaults. (#3086)
This commit is contained in:
@ -173,6 +173,7 @@ allprojects {
|
|||||||
apiVersion = "1.2"
|
apiVersion = "1.2"
|
||||||
jvmTarget = "1.8"
|
jvmTarget = "1.8"
|
||||||
javaParameters = true // Useful for reflection.
|
javaParameters = true // Useful for reflection.
|
||||||
|
freeCompilerArgs = ['-Xenable-jvm-default']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,9 +8,9 @@ import java.nio.ByteBuffer
|
|||||||
class OrdinalBits(private val ordinal: Int) {
|
class OrdinalBits(private val ordinal: Int) {
|
||||||
interface OrdinalWriter {
|
interface OrdinalWriter {
|
||||||
val bits: OrdinalBits
|
val bits: OrdinalBits
|
||||||
val encodedSize get() = 1
|
@JvmDefault val encodedSize get() = 1
|
||||||
fun writeTo(stream: OutputStream) = stream.write(bits.ordinal)
|
@JvmDefault fun writeTo(stream: OutputStream) = stream.write(bits.ordinal)
|
||||||
fun putTo(buffer: ByteBuffer) = buffer.put(bits.ordinal.toByte())!!
|
@JvmDefault fun putTo(buffer: ByteBuffer) = buffer.put(bits.ordinal.toByte())!!
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -31,6 +31,7 @@ interface AMQPSerializer<out T> {
|
|||||||
/**
|
/**
|
||||||
* Write the given object, with declared type, to the output.
|
* Write the given object, with declared type, to the output.
|
||||||
*/
|
*/
|
||||||
|
@JvmDefault
|
||||||
fun writeObject(obj: Any, data: Data, type: Type, output: SerializationOutput,
|
fun writeObject(obj: Any, data: Data, type: Type, output: SerializationOutput,
|
||||||
context: SerializationContext, debugIndent: Int = 0)
|
context: SerializationContext, debugIndent: Int = 0)
|
||||||
|
|
||||||
@ -38,4 +39,4 @@ interface AMQPSerializer<out T> {
|
|||||||
* Read the given object from the input. The envelope is provided in case the schema is required.
|
* Read the given object from the input. The envelope is provided in case the schema is required.
|
||||||
*/
|
*/
|
||||||
fun readObject(obj: Any, schemas: SerializationSchemas, input: DeserializationInput, context: SerializationContext): T
|
fun readObject(obj: Any, schemas: SerializationSchemas, input: DeserializationInput, context: SerializationContext): T
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user