1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.buralotech.oss.identifier.spring;
18
19 import com.buralotech.oss.identifier.api.IdentifierService;
20 import com.buralotech.oss.identifier.uuid.*;
21 import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
22 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
23 import org.springframework.context.annotation.Bean;
24 import org.springframework.context.annotation.Configuration;
25
26
27
28
29 @Configuration
30 public class IdentifierConfig {
31
32
33
34
35
36
37 @Bean
38 IdentifierService identifierService(final UUIDVersionDelegate delegate) {
39 return new UUIDIdentifierService(delegate);
40 }
41
42
43
44
45
46
47 @Bean
48 IdentifierConverter identifierConverter(final IdentifierService service) {
49 return new IdentifierConverter(service);
50 }
51
52 @Bean
53 @ConditionalOnProperty(name = "buralotech.identifier.generator", matchIfMissing = true, havingValue = "v7")
54 UUIDVersionDelegate version7Delegate() {
55 return new UUIDVersion7Delegate();
56 }
57
58 @Bean
59 @ConditionalOnProperty(name = "buralotech.identifier.generator", havingValue = "v6")
60 UUIDVersionDelegate version6Delegate() {
61 return new UUIDVersion6Delegate();
62 }
63
64 @Bean
65 @ConditionalOnProperty(name = "buralotech.identifier.generator", havingValue = "v1")
66 UUIDVersionDelegate version1Delegate() {
67 return new UUIDVersion1Delegate();
68 }
69 }