|
4 | 4 | */
|
5 | 5 | package org.hibernate.boot.model;
|
6 | 6 |
|
7 |
| -import java.util.HashMap; |
8 |
| -import java.util.Locale; |
9 |
| -import java.util.Map; |
10 |
| - |
11 |
| -import org.hibernate.type.descriptor.java.BasicJavaType; |
12 |
| - |
13 |
| -import org.jboss.logging.Logger; |
14 |
| - |
15 |
| -import static org.hibernate.internal.util.StringHelper.isEmpty; |
16 |
| - |
17 | 7 | /**
|
18 | 8 | * Basic implementation of {@link TypeDefinitionRegistry}.
|
19 | 9 | *
|
20 |
| - * @author Chris Cranford |
| 10 | + * @deprecated Internal code should use the internal implementation class |
| 11 | + * {@link org.hibernate.boot.internal.TypeDefinitionRegistryStandardImpl}. |
| 12 | + * This class will be removed. |
21 | 13 | */
|
22 |
| -public class TypeDefinitionRegistryStandardImpl implements TypeDefinitionRegistry { |
23 |
| - private static final Logger log = Logger.getLogger( TypeDefinitionRegistryStandardImpl.class ); |
24 |
| - |
25 |
| - private final TypeDefinitionRegistry parent; |
26 |
| - private final Map<String, TypeDefinition> typeDefinitionMap = new HashMap<>(); |
| 14 | +@Deprecated(since = "7.0", forRemoval = true) |
| 15 | +public class TypeDefinitionRegistryStandardImpl |
| 16 | + extends org.hibernate.boot.internal.TypeDefinitionRegistryStandardImpl { |
27 | 17 |
|
28 | 18 | public TypeDefinitionRegistryStandardImpl() {
|
29 |
| - this( null ); |
| 19 | + super(); |
30 | 20 | }
|
31 | 21 |
|
32 | 22 | public TypeDefinitionRegistryStandardImpl(TypeDefinitionRegistry parent) {
|
33 |
| - this.parent = parent; |
34 |
| - } |
35 |
| - |
36 |
| - @Override |
37 |
| - public TypeDefinition resolve(String typeName) { |
38 |
| - final TypeDefinition localDefinition = typeDefinitionMap.get( typeName ); |
39 |
| - if ( localDefinition != null ) { |
40 |
| - return localDefinition; |
41 |
| - } |
42 |
| - else if ( parent != null ) { |
43 |
| - return parent.resolve( typeName ); |
44 |
| - } |
45 |
| - else { |
46 |
| - return null; |
47 |
| - } |
48 |
| - } |
49 |
| - |
50 |
| - @Override |
51 |
| - public TypeDefinition resolveAutoApplied(BasicJavaType<?> jtd) { |
52 |
| - // For now, check the definition map for an entry keyed by the JTD name. |
53 |
| - // Ultimately should maybe have TypeDefinition or the registry keep explicit |
54 |
| - // track of auto-applied definitions. |
55 |
| - return jtd.getJavaType() == null ? null : typeDefinitionMap.get( jtd.getTypeName() ); |
56 |
| - } |
57 |
| - |
58 |
| - @Override |
59 |
| - public TypeDefinitionRegistry register(TypeDefinition typeDefinition) { |
60 |
| - return register( typeDefinition, DuplicationStrategy.OVERWRITE ); |
61 |
| - } |
62 |
| - |
63 |
| - @Override |
64 |
| - public TypeDefinitionRegistry register(TypeDefinition typeDefinition, DuplicationStrategy duplicationStrategy) { |
65 |
| - if ( typeDefinition == null ) { |
66 |
| - throw new IllegalArgumentException( "TypeDefinition to register cannot be null" ); |
67 |
| - } |
68 |
| - |
69 |
| - if ( typeDefinition.getTypeImplementorClass() == null ) { |
70 |
| - throw new IllegalArgumentException( "TypeDefinition to register cannot define null #typeImplementorClass" ); |
71 |
| - } |
72 |
| - |
73 |
| - if ( !isEmpty( typeDefinition.getName() ) ) { |
74 |
| - register( typeDefinition.getName(), typeDefinition, duplicationStrategy ); |
75 |
| - } |
76 |
| - |
77 |
| - if ( typeDefinition.getRegistrationKeys() != null ) { |
78 |
| - for ( String registrationKey : typeDefinition.getRegistrationKeys() ) { |
79 |
| - register( registrationKey, typeDefinition, duplicationStrategy ); |
80 |
| - } |
81 |
| - } |
82 |
| - |
83 |
| - return this; |
| 23 | + super(parent); |
84 | 24 | }
|
85 | 25 |
|
86 |
| - private void register(String name, TypeDefinition typeDefinition, DuplicationStrategy duplicationStrategy) { |
87 |
| - if ( duplicationStrategy == DuplicationStrategy.KEEP ) { |
88 |
| - if ( !typeDefinitionMap.containsKey( name ) ) { |
89 |
| - typeDefinitionMap.put( name, typeDefinition ); |
90 |
| - } |
91 |
| - } |
92 |
| - else { |
93 |
| - final TypeDefinition existing = typeDefinitionMap.put( name, typeDefinition ); |
94 |
| - if ( existing != null && existing != typeDefinition ) { |
95 |
| - if ( duplicationStrategy == DuplicationStrategy.OVERWRITE ) { |
96 |
| - log.debugf( "Overwrote existing registration [%s] for type definition.", name ); |
97 |
| - } |
98 |
| - else { |
99 |
| - throw new IllegalArgumentException( |
100 |
| - String.format( |
101 |
| - Locale.ROOT, |
102 |
| - "Attempted to overwrite registration [%s] for type definition.", |
103 |
| - name |
104 |
| - ) |
105 |
| - ); |
106 |
| - } |
107 |
| - } |
108 |
| - } |
109 |
| - } |
110 |
| - |
111 |
| - @Override |
112 |
| - public Map<String, TypeDefinition> copyRegistrationMap() { |
113 |
| - return new HashMap<>( typeDefinitionMap ); |
114 |
| - } |
115 | 26 | }
|
0 commit comments