public class MappingVaultConverter extends AbstractVaultConverter
VaultConverter
that uses a MappingContext
to do sophisticated mapping
of domain objects to SecretDocument
. This converter converts between Map-typed
representations and domain objects without use of a JSON library.
SecretDocument
is the input to JSON mapping to exchange secrets with Vault.conversions, conversionService, instantiators
Constructor and Description |
---|
MappingVaultConverter(MappingContext<? extends VaultPersistentEntity<?>,VaultPersistentProperty> mappingContext) |
Modifier and Type | Method and Description |
---|---|
protected void |
addCustomTypeKeyIfNecessary(TypeInformation<?> type,
Object value,
org.springframework.vault.repository.convert.SecretDocumentAccessor accessor)
Adds custom type information to the given
SecretDocument if necessary. |
protected List<Object> |
createCollection(Collection<?> collection,
VaultPersistentProperty property)
Writes the given
Collection using the given VaultPersistentProperty
information. |
protected Map<String,Object> |
createMap(Map<Object,Object> map,
VaultPersistentProperty property)
Writes the given
Map using the given VaultPersistentProperty
information. |
MappingContext<? extends VaultPersistentEntity<?>,VaultPersistentProperty> |
getMappingContext() |
<S> S |
read(Class<S> type,
SecretDocument source) |
protected Map<Object,Object> |
readMap(TypeInformation<?> type,
Map<String,Object> sourceMap)
|
void |
setTypeMapper(VaultTypeMapper typeMapper)
Configures the
VaultTypeMapper to be used to add type information to
SecretDocument s created by the converter and how to lookup type information
from SecretDocument s when reading them. |
void |
write(Object source,
SecretDocument sink) |
protected void |
writeInternal(Object obj,
org.springframework.vault.repository.convert.SecretDocumentAccessor sink,
TypeInformation<?> typeHint)
Internal write conversion method which should be used for nested invocations.
|
protected void |
writeInternal(Object obj,
org.springframework.vault.repository.convert.SecretDocumentAccessor sink,
VaultPersistentEntity<?> entity) |
protected Map<String,Object> |
writeMapInternal(Map<Object,Object> obj,
Map<String,Object> bson,
TypeInformation<?> propertyType)
|
protected void |
writePropertyInternal(Object obj,
org.springframework.vault.repository.convert.SecretDocumentAccessor accessor,
VaultPersistentProperty prop) |
afterPropertiesSet, getConversionService, setCustomConversions, setInstantiators
public MappingVaultConverter(MappingContext<? extends VaultPersistentEntity<?>,VaultPersistentProperty> mappingContext)
public void setTypeMapper(VaultTypeMapper typeMapper)
VaultTypeMapper
to be used to add type information to
SecretDocument
s created by the converter and how to lookup type information
from SecretDocument
s when reading them. Uses a
DefaultVaultTypeMapper
by default. Setting this to null will
reset the TypeMapper
to the default one.typeMapper
- the typeMapper to set, must not be null.public MappingContext<? extends VaultPersistentEntity<?>,VaultPersistentProperty> getMappingContext()
public <S> S read(Class<S> type, SecretDocument source)
protected Map<Object,Object> readMap(TypeInformation<?> type, Map<String,Object> sourceMap)
type
- the Map
TypeInformation
to be used to unmarshal this
Map
.sourceMap
- must not be nullMap
.public void write(Object source, SecretDocument sink)
protected void writeInternal(Object obj, org.springframework.vault.repository.convert.SecretDocumentAccessor sink, @Nullable TypeInformation<?> typeHint)
obj
- sink
- typeHint
- protected void writeInternal(Object obj, org.springframework.vault.repository.convert.SecretDocumentAccessor sink, VaultPersistentEntity<?> entity)
protected void writePropertyInternal(@Nullable Object obj, org.springframework.vault.repository.convert.SecretDocumentAccessor accessor, VaultPersistentProperty prop)
protected List<Object> createCollection(Collection<?> collection, VaultPersistentProperty property)
Collection
using the given VaultPersistentProperty
information.collection
- must not be null.property
- must not be null.List
.protected Map<String,Object> createMap(Map<Object,Object> map, VaultPersistentProperty property)
Map
using the given VaultPersistentProperty
information.map
- must not null.property
- must not be null.Map
.protected Map<String,Object> writeMapInternal(Map<Object,Object> obj, Map<String,Object> bson, TypeInformation<?> propertyType)
obj
- must not be null.bson
- must not be null.propertyType
- must not be null.Map
.protected void addCustomTypeKeyIfNecessary(@Nullable TypeInformation<?> type, Object value, org.springframework.vault.repository.convert.SecretDocumentAccessor accessor)
SecretDocument
if necessary. That
is if the value is not the same as the one given. This is usually the case if you
store a subtype of the actual declared type of the property.type
- type hint.value
- must not be null.accessor
- must not be null.Copyright © 2016–2019 Pivotal Software, Inc.. All rights reserved.