Skip to content

Commit fb98ed9

Browse files
Refactor GlobalConfigurationCategoryConfigurator to remove raw type cast in describe() (#2835)
1 parent 41f1011 commit fb98ed9

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

plugin/src/main/java/io/jenkins/plugins/casc/impl/configurators/GlobalConfigurationCategoryConfigurator.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,24 @@ protected GlobalConfigurationCategory instance(Mapping mapping, ConfigurationCon
8080
return category;
8181
}
8282

83-
@SuppressWarnings("RedundantCast") // TODO remove once we are on JDK 11
8483
@NonNull
8584
@Override
86-
public Set describe() {
87-
return (Set) Jenkins.get().getExtensionList(Descriptor.class).stream()
85+
public Set<Attribute<GlobalConfigurationCategory, ?>> describe() {
86+
return Jenkins.get().getExtensionList(Descriptor.class).stream()
8887
.filter(d -> d.getCategory() == category)
8988
.filter(d -> d.getGlobalConfigPage() != null)
9089
.map(DescriptorConfigurator::new)
9190
.filter(GlobalConfigurationCategoryConfigurator::reportDescriptorWithoutSetters)
92-
.map(c -> new Attribute<GlobalConfigurationCategory, Object>(c.getNames(), c.getTarget()).setter(NOP))
91+
.map(c -> new Attribute<GlobalConfigurationCategory, Object>(c.getNames(), c.getTarget())
92+
.setter(typedNop()))
9393
.collect(Collectors.toSet());
9494
}
9595

96+
@SuppressWarnings("unchecked")
97+
private static <T, V> Attribute.Setter<T, V> typedNop() {
98+
return (Attribute.Setter<T, V>) NOP;
99+
}
100+
96101
public static boolean reportDescriptorWithoutSetters(Configurator c) {
97102
if (c.describe().isEmpty()) {
98103
LOGGER.fine(

0 commit comments

Comments
 (0)