From 8a24b8d4582ea64d5a95eed7efdf36bf8258214f Mon Sep 17 00:00:00 2001 From: Mert Z Date: Tue, 23 Jan 2018 21:22:05 +0300 Subject: [PATCH] DATAKV-206 - Support for custom identifier generators. --- .../data/keyvalue/core/KeyValueTemplate.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main/java/org/springframework/data/keyvalue/core/KeyValueTemplate.java b/src/main/java/org/springframework/data/keyvalue/core/KeyValueTemplate.java index aa92b74f..3027b422 100644 --- a/src/main/java/org/springframework/data/keyvalue/core/KeyValueTemplate.java +++ b/src/main/java/org/springframework/data/keyvalue/core/KeyValueTemplate.java @@ -46,6 +46,7 @@ * @author Oliver Gierke * @author Thomas Darimont * @author Mark Paluch + * @author Mert Zeybekler */ public class KeyValueTemplate implements KeyValueOperations, ApplicationEventPublisherAware { @@ -88,6 +89,26 @@ public KeyValueTemplate(KeyValueAdapter adapter, this.identifierGenerator = DefaultIdentifierGenerator.INSTANCE; } + /** + * Create new {@link KeyValueTemplate} using the given {@link KeyValueAdapter} and {@link MappingContext}. + * + * @param adapter must not be {@literal null}. + * @param mappingContext must not be {@literal null}. + * @param identifierGenerator must not be {@literal null}. + */ + public KeyValueTemplate(KeyValueAdapter adapter, + MappingContext, ? extends KeyValuePersistentProperty> mappingContext, + IdentifierGenerator identifierGenerator) { + + Assert.notNull(adapter, "Adapter must not be null!"); + Assert.notNull(mappingContext, "MappingContext must not be null!"); + Assert.notNull(identifierGenerator, "IdentifierGenerator must not be null!"); + + this.adapter = adapter; + this.mappingContext = mappingContext; + this.identifierGenerator = identifierGenerator; + } + /** * Set the {@link PersistenceExceptionTranslator} used for converting {@link RuntimeException}. *