|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2020 the original author or authors. |
| 2 | + * Copyright 2012-2021 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
27 | 27 | *
|
28 | 28 | * @author Phillip Webb
|
29 | 29 | * @author Eddú Meléndez
|
| 30 | + * @author Sebastien Deleuze |
30 | 31 | */
|
31 | 32 | @SuppressWarnings("deprecation")
|
32 | 33 | final class CacheConfigurations {
|
33 | 34 |
|
34 |
| - private static final Map<CacheType, Class<?>> MAPPINGS; |
| 35 | + private static final Map<CacheType, String> MAPPINGS; |
35 | 36 |
|
36 | 37 | static {
|
37 |
| - Map<CacheType, Class<?>> mappings = new EnumMap<>(CacheType.class); |
38 |
| - mappings.put(CacheType.GENERIC, GenericCacheConfiguration.class); |
39 |
| - mappings.put(CacheType.EHCACHE, EhCacheCacheConfiguration.class); |
40 |
| - mappings.put(CacheType.HAZELCAST, HazelcastCacheConfiguration.class); |
41 |
| - mappings.put(CacheType.INFINISPAN, InfinispanCacheConfiguration.class); |
42 |
| - mappings.put(CacheType.JCACHE, JCacheCacheConfiguration.class); |
43 |
| - mappings.put(CacheType.COUCHBASE, CouchbaseCacheConfiguration.class); |
44 |
| - mappings.put(CacheType.REDIS, RedisCacheConfiguration.class); |
45 |
| - mappings.put(CacheType.CAFFEINE, CaffeineCacheConfiguration.class); |
46 |
| - mappings.put(CacheType.SIMPLE, SimpleCacheConfiguration.class); |
47 |
| - mappings.put(CacheType.NONE, NoOpCacheConfiguration.class); |
| 38 | + Map<CacheType, String> mappings = new EnumMap<>(CacheType.class); |
| 39 | + mappings.put(CacheType.GENERIC, GenericCacheConfiguration.class.getName()); |
| 40 | + mappings.put(CacheType.EHCACHE, EhCacheCacheConfiguration.class.getName()); |
| 41 | + mappings.put(CacheType.HAZELCAST, HazelcastCacheConfiguration.class.getName()); |
| 42 | + mappings.put(CacheType.INFINISPAN, InfinispanCacheConfiguration.class.getName()); |
| 43 | + mappings.put(CacheType.JCACHE, JCacheCacheConfiguration.class.getName()); |
| 44 | + mappings.put(CacheType.COUCHBASE, CouchbaseCacheConfiguration.class.getName()); |
| 45 | + mappings.put(CacheType.REDIS, RedisCacheConfiguration.class.getName()); |
| 46 | + mappings.put(CacheType.CAFFEINE, CaffeineCacheConfiguration.class.getName()); |
| 47 | + mappings.put(CacheType.SIMPLE, SimpleCacheConfiguration.class.getName()); |
| 48 | + mappings.put(CacheType.NONE, NoOpCacheConfiguration.class.getName()); |
48 | 49 | MAPPINGS = Collections.unmodifiableMap(mappings);
|
49 | 50 | }
|
50 | 51 |
|
51 | 52 | private CacheConfigurations() {
|
52 | 53 | }
|
53 | 54 |
|
54 | 55 | static String getConfigurationClass(CacheType cacheType) {
|
55 |
| - Class<?> configurationClass = MAPPINGS.get(cacheType); |
56 |
| - Assert.state(configurationClass != null, () -> "Unknown cache type " + cacheType); |
57 |
| - return configurationClass.getName(); |
| 56 | + String configurationClassName = MAPPINGS.get(cacheType); |
| 57 | + Assert.state(configurationClassName != null, () -> "Unknown cache type " + cacheType); |
| 58 | + return configurationClassName; |
58 | 59 | }
|
59 | 60 |
|
60 | 61 | static CacheType getType(String configurationClassName) {
|
61 |
| - for (Map.Entry<CacheType, Class<?>> entry : MAPPINGS.entrySet()) { |
62 |
| - if (entry.getValue().getName().equals(configurationClassName)) { |
| 62 | + for (Map.Entry<CacheType, String> entry : MAPPINGS.entrySet()) { |
| 63 | + if (entry.getValue().equals(configurationClassName)) { |
63 | 64 | return entry.getKey();
|
64 | 65 | }
|
65 | 66 | }
|
|
0 commit comments