Skip to content

Commit 7e6dbc2

Browse files
author
Phillip Webb
committed
Make TypeDescriptor more amenable to subclassing
Change the previously package scope TypeDescriptor constructor to protected and add a getResolvableType() protected method. Issue: SPR-11303
1 parent e2feed4 commit 7e6dbc2

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -109,7 +109,15 @@ public TypeDescriptor(Property property) {
109109
this.annotations = nullSafeAnnotations(property.getAnnotations());
110110
}
111111

112-
private TypeDescriptor(ResolvableType resolvableType, Class<?> type, Annotation[] annotations) {
112+
/**
113+
* Create a new type descriptor from a {@link ResolvableType}. This protected
114+
* constructor is used internally and may also be used by subclasses that support
115+
* non-Java languages with extended type systems.
116+
* @param resolvableType the resolvable type
117+
* @param type the backing type or {@code null} if should be resolved
118+
* @param annotations the type annotations
119+
*/
120+
protected TypeDescriptor(ResolvableType resolvableType, Class<?> type, Annotation[] annotations) {
113121
this.resolvableType = resolvableType;
114122
this.type = (type != null ? type : resolvableType.resolve(Object.class));
115123
this.annotations = nullSafeAnnotations(annotations);
@@ -141,6 +149,13 @@ public Class<?> getType() {
141149
return this.type;
142150
}
143151

152+
/**
153+
* Returns the underlying {@link ResolvableType}.
154+
*/
155+
protected ResolvableType getResolvableType() {
156+
return this.resolvableType;
157+
}
158+
144159
/**
145160
* Return the underlying source of the descriptor. Will return a {@link Field},
146161
* {@link MethodParameter} or {@link Type} depending on how the {@link TypeDescriptor}

0 commit comments

Comments
 (0)