DATAKV-206 - Support for custom identifier generators.

Original pull request: #29.
This commit is contained in:
Mert Z
2018-01-23 21:22:05 +03:00
committed by Mark Paluch
parent 71f946e8ff
commit e4d37f0aa6

View File

@@ -46,6 +46,7 @@ import org.springframework.util.CollectionUtils;
* @author Oliver Gierke
* @author Thomas Darimont
* @author Mark Paluch
* @author Mert Zeybekler
*/
public class KeyValueTemplate implements KeyValueOperations, ApplicationEventPublisherAware {
@@ -88,6 +89,26 @@ public class KeyValueTemplate implements KeyValueOperations, ApplicationEventPub
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 KeyValuePersistentEntity<?, ?>, ? 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}.
*