You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the numberOfUsages parameter for ReferenceDeciderForType is calculated by the number of setters which are going to consume the referenced item. This is a good estimate, but in general not correct for any case: For example, consider a Schema which is multiply used by identical ApiResponses, but in turn this ApiResponse is also referenced itself. Then the actual usage of that schema is 1, as the Schema is only used by one ApiResponse, but the number of setters is not merged in AbstractReferencedItemStorage, as the referencing of ApiResponses happens later than the referencing of Schemas.
Have a look at AbstractReferencedItemStorage method for a starting idea:
@Nullable
private Object findSetterTarget(Consumer<T> setter) {
Field[] declaredFields = setter.getClass().getDeclaredFields();
if (declaredFields.length == 1) {
Field declaredField = declaredFields[0];
declaredField.setAccessible(true);
try {
return declaredField.get(setter);
} catch (IllegalAccessException e) {
// this should not happen, as we've made it accessible...
return null;
}
}
return null;
}
This is a hard issue, but you can learn a lot about how referencing of items is done internally in this library.
The text was updated successfully, but these errors were encountered:
Currently, the
numberOfUsages
parameter forReferenceDeciderForType
is calculated by the number of setters which are going to consume the referenced item. This is a good estimate, but in general not correct for any case: For example, consider aSchema
which is multiply used by identicalApiResponse
s, but in turn thisApiResponse
is also referenced itself. Then the actual usage of that schema is 1, as the Schema is only used by one ApiResponse, but the number of setters is not merged inAbstractReferencedItemStorage
, as the referencing of ApiResponses happens later than the referencing of Schemas.Have a look at
AbstractReferencedItemStorage
method for a starting idea:This is a hard issue, but you can learn a lot about how referencing of items is done internally in this library.
The text was updated successfully, but these errors were encountered: