SerializationContext - corda

corda / net.corda.core.serialization / SerializationContext

# SerializationContext

`@DoNotImplement interface SerializationContext`

Parameters to serialization and deserialization.

### Types

#### UseCase | The use case that we are serializing for, since it influences the implementations chosen. `enum class UseCase`

### Properties

#### carpenterDisabled | If true, deserialization calls using this context will not fallback to using the Class Carpenter to attempt to construct classes present in the schema but not on the current classpath. `abstract val carpenterDisabled: Boolean`
#### customSerializers | Additional custom serializers that will be made available during (de)serialization. `abstract val customSerializers: Set<SerializationCustomSerializer<*, *>>`
#### deserializationClassLoader | The class loader to use for deserialization. `abstract val deserializationClassLoader: ClassLoader`
#### encoding | If non-null, apply this encoding (typically compression) when serializing. `abstract val encoding: SerializationEncoding?`
#### encodingWhitelist | A whitelist that determines (mostly for security purposes) whether a particular encoding may be used when deserializing. `abstract val encodingWhitelist: EncodingWhitelist`
#### lenientCarpenterEnabled | If true the carpenter will happily synthesis classes that implement interfaces containing methods that are not getters for any AMQP fields. Invoking these methods will throw an AbstractMethodError. If false then an exception will be thrown during deserialization instead. `abstract val lenientCarpenterEnabled: Boolean`
#### objectReferencesEnabled | Duplicate references to the same object preserved in the wire format and when deserialized when this is true, otherwise they appear as new copies of the object. `abstract val objectReferencesEnabled: Boolean`
#### preferredSerializationVersion | When serializing, use the format this header sequence represents. `abstract val preferredSerializationVersion: SerializationMagic`
#### preventDataLoss | If true the serialization evolver will fail if the binary to be deserialized contains more fields then the current object from the classpath. `abstract val preventDataLoss: Boolean`
#### properties | A map of any additional properties specific to the particular use case. `abstract val properties: Map<Any, Any>`
#### useCase | The use case we are serializing or deserializing for. See UseCase. `abstract val useCase: UseCase`
#### whitelist | A whitelist that contains (mostly for security purposes) which classes can be serialized and deserialized. `abstract val whitelist: ClassWhitelist`

### Functions

#### withAttachmentsClassLoader | Does not do anything. `abstract fun withAttachmentsClassLoader(attachmentHashes: List<SecureHash>): SerializationContext`
#### withClassLoader | Helper method to return a new context based on this context with the deserialization class loader changed. `abstract fun withClassLoader(classLoader: ClassLoader): SerializationContext`
#### withCustomSerializers | Helper method to return a new context based on this context with the given serializers added. `abstract fun withCustomSerializers(serializers: Set<SerializationCustomSerializer<*, *>>): SerializationContext`
#### withEncoding | A shallow copy of this context but with the given (possibly null) encoding. `abstract fun withEncoding(encoding: SerializationEncoding?): SerializationContext`
#### withEncodingWhitelist | A shallow copy of this context but with the given encoding whitelist. `abstract fun withEncodingWhitelist(encodingWhitelist: EncodingWhitelist): SerializationContext`
#### withLenientCarpenter | Return a new context based on this one but with a lenient carpenter. `abstract fun withLenientCarpenter(): SerializationContext`
#### withoutCarpenter | Returns a copy of the current context with carpentry of unknown classes disabled. On encountering such a class during deserialization the Serialization framework will throw a NotSerializableException. `abstract fun withoutCarpenter(): SerializationContext`
#### withoutReferences | Helper method to return a new context based on this context with object references disabled. `abstract fun withoutReferences(): SerializationContext`
#### withPreferredSerializationVersion | Helper method to return a new context based on this context but with serialization using the format this header sequence represents. `abstract fun withPreferredSerializationVersion(magic: SerializationMagic): SerializationContext`
#### withPreventDataLoss | Return a new context based on this one but with a strict evolution. `abstract fun withPreventDataLoss(): SerializationContext`
#### withProperties | Helper method to return a new context based on this context with the extra properties added. `abstract fun withProperties(extraProperties: Map<Any, Any>): SerializationContext`
#### withProperty | Helper method to return a new context based on this context with the property added. `abstract fun withProperty(property: Any, value: Any): SerializationContext`
#### withWhitelisted | Helper method to return a new context based on this context with the given class specifically whitelisted. `abstract fun withWhitelisted(clazz: Class<*>): SerializationContext`

### Extension Functions

#### withWhitelist | Helper method to return a new context based on this context with the given list of classes specifically whitelisted. `fun SerializationContext.withWhitelist(classes: List<Class<*>>): SerializationContext`