Skip to content

Commit e4d37f0

Browse files
Mert-Zmp911de
authored andcommitted
DATAKV-206 - Support for custom identifier generators.
Original pull request: #29.
1 parent 71f946e commit e4d37f0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/main/java/org/springframework/data/keyvalue/core/KeyValueTemplate.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
* @author Oliver Gierke
4747
* @author Thomas Darimont
4848
* @author Mark Paluch
49+
* @author Mert Zeybekler
4950
*/
5051
public class KeyValueTemplate implements KeyValueOperations, ApplicationEventPublisherAware {
5152

@@ -88,6 +89,26 @@ public KeyValueTemplate(KeyValueAdapter adapter,
8889
this.identifierGenerator = DefaultIdentifierGenerator.INSTANCE;
8990
}
9091

92+
/**
93+
* Create new {@link KeyValueTemplate} using the given {@link KeyValueAdapter} and {@link MappingContext}.
94+
*
95+
* @param adapter must not be {@literal null}.
96+
* @param mappingContext must not be {@literal null}.
97+
* @param identifierGenerator must not be {@literal null}.
98+
*/
99+
public KeyValueTemplate(KeyValueAdapter adapter,
100+
MappingContext<? extends KeyValuePersistentEntity<?, ?>, ? extends KeyValuePersistentProperty<?>> mappingContext,
101+
IdentifierGenerator identifierGenerator) {
102+
103+
Assert.notNull(adapter, "Adapter must not be null!");
104+
Assert.notNull(mappingContext, "MappingContext must not be null!");
105+
Assert.notNull(identifierGenerator, "IdentifierGenerator must not be null!");
106+
107+
this.adapter = adapter;
108+
this.mappingContext = mappingContext;
109+
this.identifierGenerator = identifierGenerator;
110+
}
111+
91112
/**
92113
* Set the {@link PersistenceExceptionTranslator} used for converting {@link RuntimeException}.
93114
*

0 commit comments

Comments
 (0)