mirror of
https://github.com/corda/corda.git
synced 2025-06-16 14:18:20 +00:00
Minor: add a utility to OpaqueBytes
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
package com.r3corda.core.serialization
|
package com.r3corda.core.serialization
|
||||||
|
|
||||||
import com.google.common.io.BaseEncoding
|
import com.google.common.io.BaseEncoding
|
||||||
|
import java.io.ByteArrayInputStream
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,6 +28,9 @@ open class OpaqueBytes(val bits: ByteArray) {
|
|||||||
override fun toString() = "[" + BaseEncoding.base16().encode(bits) + "]"
|
override fun toString() = "[" + BaseEncoding.base16().encode(bits) + "]"
|
||||||
|
|
||||||
val size: Int get() = bits.size
|
val size: Int get() = bits.size
|
||||||
|
|
||||||
|
/** Returns a [ByteArrayInputStream] of the bytes */
|
||||||
|
fun open() = ByteArrayInputStream(bits)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ByteArray.opaque(): OpaqueBytes = OpaqueBytes(this)
|
fun ByteArray.opaque(): OpaqueBytes = OpaqueBytes(this)
|
||||||
|
Reference in New Issue
Block a user