@@ -36,6 +36,10 @@ protected BeanDescription(JavaType type) {
36
36
_type = type ;
37
37
}
38
38
39
+ public BeanDescription .Supplier supplier () {
40
+ return new EagerSupplier (this );
41
+ }
42
+
39
43
/*
40
44
/**********************************************************************
41
45
/* Simple accessors
@@ -303,30 +307,45 @@ public AnnotatedMember findJsonKeyAccessor() {
303
307
/**
304
308
* Base implementation for lazily-constructed suppliers for {@link BeanDescription} instances.
305
309
*/
306
- public static abstract class Supplier implements java .util .function .Supplier <BeanDescription >
310
+ public interface Supplier extends java .util .function .Supplier <BeanDescription >
311
+ {
312
+ JavaType getType ();
313
+
314
+ default Class <?> getBeanClass () { return getType ().getRawClass (); }
315
+
316
+ default boolean isRecordType () { return getType ().isRecordType (); }
317
+
318
+ default AnnotatedClass getClassInfo () {
319
+ return get ().getClassInfo ();
320
+ }
321
+
322
+ default Annotations getClassAnnotations () {
323
+ return get ().getClassAnnotations ();
324
+ }
325
+
326
+ @ Override
327
+ public BeanDescription get ();
328
+ }
329
+
330
+ public static abstract class LazySupplier implements Supplier
307
331
{
308
- private final JavaType _type ;
332
+ protected final JavaType _type ;
309
333
310
- private transient BeanDescription _beanDesc ;
334
+ protected transient BeanDescription _beanDesc ;
311
335
312
- protected Supplier (JavaType type ) {
336
+ protected LazySupplier (JavaType type ) {
313
337
_type = type ;
314
338
}
315
339
340
+ @ Override
316
341
public JavaType getType () { return _type ; }
317
342
343
+ @ Override
318
344
public Class <?> getBeanClass () { return _type .getRawClass (); }
319
345
346
+ @ Override
320
347
public boolean isRecordType () { return _type .isRecordType (); }
321
348
322
- public AnnotatedClass getClassInfo () {
323
- return get ().getClassInfo ();
324
- }
325
-
326
- public Annotations getClassAnnotations () {
327
- return get ().getClassAnnotations ();
328
- }
329
-
330
349
@ Override
331
350
public BeanDescription get () {
332
351
if (_beanDesc == null ) {
@@ -337,4 +356,19 @@ public BeanDescription get() {
337
356
338
357
protected abstract BeanDescription _construct (JavaType forType );
339
358
}
359
+
360
+ public static class EagerSupplier implements Supplier
361
+ {
362
+ protected final BeanDescription _beanDesc ;
363
+
364
+ public EagerSupplier (BeanDescription beanDesc ) {
365
+ _beanDesc = Objects .requireNonNull (beanDesc );
366
+ }
367
+
368
+ @ Override
369
+ public JavaType getType () { return _beanDesc .getType (); }
370
+
371
+ @ Override
372
+ public BeanDescription get () { return _beanDesc ; }
373
+ }
340
374
}
0 commit comments