Skip to content

Commit

Permalink
refactor: restrict method visibility and improve method name.
Browse files Browse the repository at this point in the history
  • Loading branch information
renanfranca committed May 31, 2024
1 parent 83b906e commit ad82b67
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static Function<VersionSlug, Optional<JavaDependencyVersion>> toVersion(
return toVersion(currentVersions, projectDependencies, List.of());
}

public static Function<VersionSlug, Optional<JavaDependencyVersion>> toVersion(
private static Function<VersionSlug, Optional<JavaDependencyVersion>> toVersion(
JavaDependenciesVersions currentVersions,
ProjectJavaDependencies projectDependencies,
Collection<JavaBuildCommand> dependencyCommands
Expand All @@ -89,14 +89,18 @@ private static Function<JavaDependencyVersion, Optional<JavaDependencyVersion>>
Collection<JavaBuildCommand> dependencyCommands
) {
return version -> {
if (version.equals(currentVersion) && dependencyCommands.stream().noneMatch(AddDirectJavaDependency.class::isInstance)) {
if (version.equals(currentVersion) && hasNoAddDirectJavaDependency(dependencyCommands)) {
return Optional.empty();
}

return Optional.of(currentVersion);
};
}

private static boolean hasNoAddDirectJavaDependency(Collection<JavaBuildCommand> dependencyCommands) {
return dependencyCommands.stream().noneMatch(AddDirectJavaDependency.class::isInstance);
}

private Function<JavaDependencyVersion, JavaBuildCommand> toSetVersionCommand() {
return SetVersion::new;
}
Expand Down

0 comments on commit ad82b67

Please sign in to comment.