Iterable<Tag> vs Iterable<? extends Tag> (original) (raw)
I noticed that Micrometer methods sometimes accept Iterable<? extends Tag>:
$ git grep 'Iterable<? extends Tag>' micrometer-core/src/main/java/io/micrometer/core/instrument/Tags.java: public Tags and(@Nullable Iterable<? extends Tag> tags) { micrometer-core/src/main/java/io/micrometer/core/instrument/Tags.java: public static Tags concat(@Nullable Iterable<? extends Tag> tags, @Nullable Iterable otherTags) { micrometer-core/src/main/java/io/micrometer/core/instrument/Tags.java: public static Tags concat(@Nullable Iterable<? extends Tag> tags, @Nullable String... keyValues) { micrometer-core/src/main/java/io/micrometer/core/instrument/Tags.java: public static Tags of(@Nullable Iterable<? extends Tag> tags) {
... but mostly require Iterable<Tag>:
$ git grep -l 'Iterable' | wc -l 88
Two questions:
- For consistency, shouldn't the second argument to
Tags.concatalso acceptIterable<? extends Tag>? - Since
Tagis an interface and even has a public subtype provided by Micrometer itself (ImmutableTag), shouldn't most/all other methods also accept anIterable<? extends Tag>?
(I'm raising this question mostly because it came up while writing a Refaster template. I can understand if the suggested changes aren't worth potentially breaking client code, even though I expect that the suggested changes are mostly safe. If there's interest in this change I'm willing to prepare a PR.)