Skip to content

Add sub classing interfaces#372

Open
fynnjuranek wants to merge 2 commits into
micrometer-metrics:mainfrom
fynnjuranek:match-sub-classing-interfaces
Open

Add sub classing interfaces#372
fynnjuranek wants to merge 2 commits into
micrometer-metrics:mainfrom
fynnjuranek:match-sub-classing-interfaces

Conversation

@fynnjuranek

@fynnjuranek fynnjuranek commented Apr 28, 2025

Copy link
Copy Markdown
Contributor

This implementation enables sub-classing of the documentation interfaces, in order to get them recognized by the plugin as described in #338.
I've added some tests to ensure it behaves as expected, let me know if I should add some more cases.

This closes gh-338

Signed-off-by: Fynn Juranek <fynnjuranek@web.de>
Signed-off-by: Fynn Juranek <fynnjuranek@web.de>

@marcingrzejszczak marcingrzejszczak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

I wonder if that will work if the extension interface comes outside of our sources. I doubt it.

I start to wonder if we shouldn't think of putting more priority on creating some JSON like metadata that can later get merged - #130

Comment on lines +59 to +60
private final Collection<Class<?>> supportedInterfaces = new ArrayList<>(
Arrays.asList(SpanDocumentation.class, ObservationDocumentation.class));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this work?

Suggested change
private final Collection<Class<?>> supportedInterfaces = new ArrayList<>(
Arrays.asList(SpanDocumentation.class, ObservationDocumentation.class));
private final Collection<Class<?>> supportedInterfaces = Arrays.asList(SpanDocumentation.class, ObservationDocumentation.class);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not work, as Arrays.asList creates an immutable list, but I'm adding the found extending interfaces to the supportedInterfaces array. See AbstractSearchingFileVisitor.java#L81.

But maybe there is a better way of doing this, which I didn't think of?

Comment on lines +59 to +60
private final Collection<Class<?>> supportedInterfaces = new ArrayList<>(
Arrays.asList(MeterDocumentation.class, ObservationDocumentation.class));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this work?

Suggested change
private final Collection<Class<?>> supportedInterfaces = new ArrayList<>(
Arrays.asList(MeterDocumentation.class, ObservationDocumentation.class));
private final Collection<Class<?>> supportedInterfaces = Arrays.asList(MeterDocumentation.class, ObservationDocumentation.class);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not work, as Arrays.asList creates an immutable list, but I'm adding the found extending interfaces to the supportedInterfaces array. See AbstractSearchingFileVisitor.java#L81.

But maybe there is a better way of doing this, which I didn't think of?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Match sub-classing interfaces

3 participants