@@ -47,23 +47,31 @@ public abstract class ReflectionConfigurationParser<C, T> extends ConfigurationP
47
47
48
48
protected final ConfigurationConditionResolver <C > conditionResolver ;
49
49
protected final ReflectionConfigurationParserDelegate <C , T > delegate ;
50
+ protected final String combinedFileKey ;
50
51
private final boolean printMissingElements ;
51
52
52
53
public ReflectionConfigurationParser (ConfigurationConditionResolver <C > conditionResolver , ReflectionConfigurationParserDelegate <C , T > delegate , boolean strictConfiguration ,
53
- boolean printMissingElements ) {
54
+ boolean printMissingElements , String combinedFileKey ) {
54
55
super (strictConfiguration );
55
56
this .conditionResolver = conditionResolver ;
56
57
this .printMissingElements = printMissingElements ;
57
58
this .delegate = delegate ;
59
+ this .combinedFileKey = combinedFileKey ;
58
60
}
59
61
60
62
public static <C , T > ReflectionConfigurationParser <C , T > create (String combinedFileKey , boolean strictMetadata ,
61
63
ConfigurationConditionResolver <C > conditionResolver , ReflectionConfigurationParserDelegate <C , T > delegate ,
62
64
boolean strictConfiguration , boolean printMissingElements , boolean treatAllEntriesAsType ) {
65
+ return create (combinedFileKey , strictMetadata , conditionResolver , delegate , strictConfiguration , printMissingElements , treatAllEntriesAsType , false );
66
+ }
67
+
68
+ public static <C , T > ReflectionConfigurationParser <C , T > create (String combinedFileKey , boolean strictMetadata ,
69
+ ConfigurationConditionResolver <C > conditionResolver , ReflectionConfigurationParserDelegate <C , T > delegate ,
70
+ boolean strictConfiguration , boolean printMissingElements , boolean treatAllEntriesAsType , boolean typeOnly ) {
63
71
if (strictMetadata ) {
64
- return new ReflectionMetadataParser <>(combinedFileKey , conditionResolver , delegate , strictConfiguration , printMissingElements );
72
+ return new ReflectionMetadataParser <>(combinedFileKey , conditionResolver , delegate , strictConfiguration , printMissingElements , typeOnly );
65
73
} else {
66
- return new LegacyReflectionConfigurationParser <>(conditionResolver , delegate , strictConfiguration , printMissingElements , treatAllEntriesAsType );
74
+ return new LegacyReflectionConfigurationParser <>(conditionResolver , delegate , strictConfiguration , printMissingElements , treatAllEntriesAsType , typeOnly );
67
75
}
68
76
}
69
77
@@ -76,8 +84,8 @@ protected void parseClassArray(List<Object> classes) {
76
84
protected abstract void parseClass (EconomicMap <String , Object > data );
77
85
78
86
protected void registerIfNotDefault (EconomicMap <String , Object > data , boolean defaultValue , T clazz , String propertyName , Runnable register ) {
79
- if (data .containsKey (propertyName )) {
80
- RuntimeReflectionSupport .increaseCount (false );
87
+ if (data .containsKey (propertyName ) && delegate . getClass (). getName (). contains ( "ReflectionRegistryAdapter" ) ) {
88
+ RuntimeReflectionSupport .increaseCount (combinedFileKey . equals ( REFLECTION_KEY ) );
81
89
}
82
90
if (data .containsKey (propertyName ) ? asBoolean (data .get (propertyName ), propertyName ) : defaultValue ) {
83
91
try {
@@ -96,7 +104,9 @@ protected void parseFields(C condition, List<Object> fields, T clazz) {
96
104
97
105
private void parseField (C condition , EconomicMap <String , Object > data , T clazz ) {
98
106
checkAttributes (data , "reflection field descriptor object" , Collections .singleton ("name" ), Arrays .asList ("allowWrite" , "allowUnsafeAccess" ));
99
- RuntimeReflectionSupport .increaseCount (false );
107
+ if (delegate .getClass ().getName ().contains ("ReflectionRegistryAdapter" )) {
108
+ RuntimeReflectionSupport .increaseCount (combinedFileKey .equals (REFLECTION_KEY ));
109
+ }
100
110
String fieldName = asString (data .get ("name" ), "name" );
101
111
boolean allowWrite = data .containsKey ("allowWrite" ) && asBoolean (data .get ("allowWrite" ), "allowWrite" );
102
112
@@ -117,7 +127,9 @@ protected void parseMethods(C condition, boolean queriedOnly, List<Object> metho
117
127
118
128
private void parseMethod (C condition , boolean queriedOnly , EconomicMap <String , Object > data , T clazz ) {
119
129
checkAttributes (data , "reflection method descriptor object" , Collections .singleton ("name" ), Collections .singleton ("parameterTypes" ));
120
- RuntimeReflectionSupport .increaseCount (false );
130
+ if (delegate .getClass ().getName ().contains ("ReflectionRegistryAdapter" )) {
131
+ RuntimeReflectionSupport .increaseCount (combinedFileKey .equals (REFLECTION_KEY ));
132
+ }
121
133
String methodName = asString (data .get ("name" ), "name" );
122
134
List <T > methodParameterTypes = null ;
123
135
Object parameterTypes = data .get ("parameterTypes" );
0 commit comments