Declare serialisation default interface methods as Java8-style defaults. (#3086)

This commit is contained in:
Chris Rankin 2018-05-18 12:31:01 +01:00 committed by GitHub
parent 215e54f1ab
commit a38250c100
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View File

@ -173,6 +173,7 @@ allprojects {
apiVersion = "1.2"
jvmTarget = "1.8"
javaParameters = true // Useful for reflection.
freeCompilerArgs = ['-Xenable-jvm-default']
}
}

View File

@ -8,9 +8,9 @@ import java.nio.ByteBuffer
class OrdinalBits(private val ordinal: Int) {
interface OrdinalWriter {
val bits: OrdinalBits
val encodedSize get() = 1
fun writeTo(stream: OutputStream) = stream.write(bits.ordinal)
fun putTo(buffer: ByteBuffer) = buffer.put(bits.ordinal.toByte())!!
@JvmDefault val encodedSize get() = 1
@JvmDefault fun writeTo(stream: OutputStream) = stream.write(bits.ordinal)
@JvmDefault fun putTo(buffer: ByteBuffer) = buffer.put(bits.ordinal.toByte())!!
}
init {

View File

@ -31,6 +31,7 @@ interface AMQPSerializer<out T> {
/**
* Write the given object, with declared type, to the output.
*/
@JvmDefault
fun writeObject(obj: Any, data: Data, type: Type, output: SerializationOutput,
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.
*/
fun readObject(obj: Any, schemas: SerializationSchemas, input: DeserializationInput, context: SerializationContext): T
}
}