corda / net.corda.core.utilities

Package net.corda.core.utilities

Corda utility classes, providing a broad range of functionality to help implement both Corda nodes and CorDapps.

Types

ByteSequence

sealed class ByteSequence : Comparable<ByteSequence>

An abstraction of a byte array, with offset and size that does no copying of bytes unless asked to.

NetworkHostAndPort

data class NetworkHostAndPort

Tuple of host and port. Use NetworkHostAndPort.parse on untrusted data.

NonEmptySet

class NonEmptySet<T> : Set<T>

An immutable ordered non-empty set.

OpaqueBytes

open class OpaqueBytes : ByteSequence

A simple class that wraps a byte array and makes the equals/hashCode/toString methods work as you actually expect. In an ideal JVM this would be a value type and be completely overhead free. Project Valhalla is adding such functionality to Java, but it won't arrive for a few years yet!

OpaqueBytesSubSequence

class OpaqueBytesSubSequence : ByteSequence

Class is public for serialization purposes

ProgressTracker

class ProgressTracker

A progress tracker helps surface information about the progress of an operation to a user interface or API of some kind. It lets you define a set of steps that represent an operation. A step is represented by an object (typically a singleton).

PropertyDelegate

interface PropertyDelegate<out T>

Simple interface encapsulating the implicit Kotlin contract for immutable property delegates.

Try

sealed class Try<out A>

Representation of an operation that has either succeeded with a result (represented by Success) or failed with an exception (represented by Failure).

UntrustworthyData

class UntrustworthyData<out T>

A small utility to approximate taint tracking: if a method gives you back one of these, it means the data came from a remote source that may be incentivised to pass us junk that violates basic assumptions and thus must be checked first. The wrapper helps you to avoid forgetting this vital step. Things you might want to check are:

VariablePropertyDelegate

interface VariablePropertyDelegate<T> : PropertyDelegate<T>

Simple interface encapsulating the implicit Kotlin contract for mutable property delegates.

Extensions for External Classes

java.security.PublicKey

java.util.concurrent.Future

kotlin.ByteArray

kotlin.Int

kotlin.Long

kotlin.String

kotlin.collections.Collection

org.slf4j.Logger

Functions

loggerFor

fun <T : Any> loggerFor(): Logger

Get the Logger for a class using the syntax

parsePublicKeyBase58

fun parsePublicKeyBase58(base58String: String): PublicKey

transient

fun <T> transient(initializer: () -> T): PropertyDelegate<T>

A simple wrapper that enables the use of Kotlin's val x by transient { ... } syntax. Such a property will not be serialized, and if it's missing (or the first time it's accessed), the initializer will be used to set it up.

unwrap

fun <T, R> UntrustworthyData<T>.unwrap(validator: (T) -> R): R