Skip to content

Commit

Permalink
code cleanup (#812)
Browse files Browse the repository at this point in the history
* code cleanup

* Not a redundant cast on JDK 8
  • Loading branch information
jetersen committed Mar 31, 2019
1 parent f16aebb commit 006f76c
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,7 @@ public FormValidation doCheckNewSource(@QueryParameter String newSource) {
return FormValidation.warning(warnings.toString());
}
return FormValidation.okWithMarkup("The configuration can be applied");
} catch (ConfiguratorException e) {
return FormValidation.error(e, e.getCause().getMessage());
} catch (IllegalArgumentException e) {
} catch (ConfiguratorException | IllegalArgumentException e) {
return FormValidation.error(e, e.getCause().getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected UpdateCenter instance(Mapping mapping, ConfigurationContext context) t
return new HashSet<>(Collections.singletonList(
new MultivaluedAttribute<UpdateCenter, UpdateSite>("sites", UpdateSite.class)
.getter(UpdateCenter::getSiteList)
.setter((target, value) -> { target.getSites().replaceBy(value); })
.setter((target, value) -> target.getSites().replaceBy(value))
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ private T tryConstructor(Constructor<T> constructor, Mapping config, Configurati
}

// constructor was successful, so let's removed configuration elements we have consumed doing so.
for (int i = 0; i < names.length; i++) {
config.remove(names[i]);
for (String name : names) {
config.remove(name);
}

return object;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected T instance(Mapping mapping, ConfigurationContext context) throws Confi
if (list.size() != 1) {
throw new ConfiguratorException("Expected a unique instance of extension "+target);
}
return (T) list.get(0);
return list.get(0);
}

@CheckForNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ protected GlobalConfigurationCategory instance(Mapping mapping, ConfigurationCon
return category;
}

@SuppressWarnings("RedundantCast") // TODO remove once we are on JDK 11
@NonNull
@Override
public Set describe() {
return (Set) Jenkins.getInstance().getExtensionList(Descriptor.class).stream()
.filter(d -> d.getCategory() == category)
.filter(d -> d.getGlobalConfigPage() != null)
.map(d -> new DescriptorConfigurator(d))
.map(DescriptorConfigurator::new)
.filter(GlobalConfigurationCategoryConfigurator::reportDescriptorWithoutSetters)
.map(c -> new Attribute<GlobalConfigurationCategory, Object>(c.getName(), c.getTarget()).setter(NOP))
.collect(Collectors.toSet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private static void merge(Node root, Node node, String source) throws Configurat
return;
default:
throw new ConfiguratorException(
String.format("Found conflicting configuration at %s %s", source.toString(), node.getStartMark()));
String.format("Found conflicting configuration at %s %s", source, node.getStartMark()));
}

}
Expand Down

0 comments on commit 006f76c

Please sign in to comment.