Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace explicit type with <> #935

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -30,7 +30,7 @@ public class ArgumentParser {
private final String programName;
private final List<Flag> flags;
private final List<Input> inputs;
private final Map<String, Flag> names = new HashMap<String, Flag>();
private final Map<String, Flag> names = new HashMap<>();
private final boolean shouldShowHelp;

public ArgumentParser(String programName, List<Flag> flags) {
@@ -39,7 +39,7 @@ public ArgumentParser(String programName, List<Flag> flags) {

public ArgumentParser(String programName, List<Flag> flags, List<Input> inputs) {
this.programName = programName;
this.flags = new ArrayList<Flag>(flags);
this.flags = new ArrayList<>(flags);
this.inputs = inputs;

if (!flags.stream().anyMatch(f -> f.shortcut().equals("h") && f.fullname().equals("help"))) {
@@ -27,7 +27,7 @@

public class Arguments {
private final List<String> positionals;
private final Map<String, FlagValue> names = new HashMap<String, FlagValue>();
private final Map<String, FlagValue> names = new HashMap<>();

public Arguments(List<FlagValue> flags, List<String> positionals) {
this.positionals = positionals;
@@ -115,7 +115,7 @@ public Collection<WorkItem> run(Path scratch) {
log.info("Found existing Hg repository at: " + to);
var toRepo = Repository.get(to).orElseThrow(() ->
new IllegalStateException("Repository vanished from " + to));
var existing = new ArrayList<Mark>(marks.current());
var existing = new ArrayList<>(marks.current());
log.info("Found " + existing.size() + " existing marks");

var convertedGitHashes = existing.stream().map(Mark::git).collect(Collectors.toSet());
@@ -367,7 +367,7 @@ public Collection<WorkItem> run(Path scratchPath) {
var freq = spec.frequency().get();
if (freq.isHourly()) {
if (!hourly.containsKey(desc)) {
hourly.put(desc, new HashSet<Integer>());
hourly.put(desc, new HashSet<>());
}
var minute = now.getMinute();
var hour = now.getHour();
@@ -378,7 +378,7 @@ public Collection<WorkItem> run(Path scratchPath) {
}
} else if (freq.isDaily()) {
if (!daily.containsKey(desc)) {
daily.put(desc, new HashSet<Integer>());
daily.put(desc, new HashSet<>());
}
var hour = now.getHour();
var day = now.getDayOfYear();
@@ -389,7 +389,7 @@ public Collection<WorkItem> run(Path scratchPath) {
}
} else if (freq.isWeekly()) {
if (!weekly.containsKey(desc)) {
weekly.put(desc, new HashSet<Integer>());
weekly.put(desc, new HashSet<>());
}
var weekOfYear = now.get(WeekFields.ISO.weekOfYear());
var weekday = now.getDayOfWeek();
@@ -403,7 +403,7 @@ public Collection<WorkItem> run(Path scratchPath) {
}
} else if (freq.isMonthly()) {
if (!monthly.containsKey(desc)) {
monthly.put(desc, new HashSet<Month>());
monthly.put(desc, new HashSet<>());
}
var day = now.getDayOfMonth();
var hour = now.getHour();
@@ -416,7 +416,7 @@ public Collection<WorkItem> run(Path scratchPath) {
}
} else if (freq.isYearly()) {
if (!yearly.containsKey(desc)) {
yearly.put(desc, new HashSet<Integer>());
yearly.put(desc, new HashSet<>());
}
var month = now.getMonth();
var day = now.getDayOfMonth();
@@ -273,7 +273,7 @@ private static List<List<Issue>> groupByReleaseStream(List<Issue> issues) {
var streams = releaseStreams(fixVersion.get());
for (var stream : streams) {
if (!streamIssues.containsKey(stream)) {
streamIssues.put(stream, new ArrayList<Issue>());
streamIssues.put(stream, new ArrayList<>());
}
streamIssues.get(stream).add(issue);
}
@@ -164,7 +164,7 @@ private void appendBuildsSection(StringBuilder summary, Job job) {
var osAndArch = osDisplayName(build.os()) + " " + cpuDisplayName(build.cpu());
var debugLevel = debugLevelDisplayName(build.debugLevel());
if (!perOSandArch.containsKey(osAndArch)) {
perOSandArch.put(osAndArch, new ArrayList<String>());
perOSandArch.put(osAndArch, new ArrayList<>());
}
perOSandArch.get(osAndArch).add(debugLevel);
}
@@ -78,7 +78,7 @@ private static String getCPU() {
@Override
public void apply(Project project) {
NamedDomainObjectContainer<ImageEnvironment> imageEnvironmentContainer =
project.container(ImageEnvironment.class, new NamedDomainObjectFactory<ImageEnvironment>() {
project.container(ImageEnvironment.class, new NamedDomainObjectFactory<>() {
public ImageEnvironment create(String name) {
return new ImageEnvironment(name, project.getObjects());
}
@@ -90,7 +90,7 @@ public ImageEnvironment create(String name) {
var rootDir = project.getRootDir().toPath().toAbsolutePath();
var buildDir = project.getBuildDir().toPath().toAbsolutePath();

imageEnvironmentContainer.all(new Action<ImageEnvironment>() {
imageEnvironmentContainer.all(new Action<>() {
public void execute(ImageEnvironment env) {
var parts = env.getName().split("_");;
var isLocal = parts.length == 1 && parts[0].equals("local");
@@ -152,7 +152,7 @@ void link() throws IOException {
uniqueModules.add(entry.substring(0, firstSlash));
}
uniqueModules.addAll(modules.get());
var allModules = new ArrayList<String>(uniqueModules);
var allModules = new ArrayList<>(uniqueModules);

Files.createDirectories(toDir.get());
var dest = toDir.get().resolve(os.get() + "-" + cpu.get());
@@ -40,7 +40,7 @@ public OpensDirective(String packageName, Map<String, List<String>> map) {

public void to(String moduleName) {
if (!map.containsKey(packageName)) {
map.put(packageName, new ArrayList<String>());
map.put(packageName, new ArrayList<>());
}

map.get(packageName).add(moduleName);
@@ -49,8 +49,8 @@ public void to(String moduleName) {

private final Property<String> name;

private final List<String> requires = new ArrayList<String>();
private final Map<String, List<String>> opens = new TreeMap<String, List<String>>();
private final List<String> requires = new ArrayList<>();
private final Map<String, List<String>> opens = new TreeMap<>();

public ModuleExtension(Project project) {
name = project.getObjects().property(String.class);
@@ -49,7 +49,7 @@ public void apply(Project project) {
for (var task : project.getTasksByName("compileJava", false)) {
if (task instanceof JavaCompile) {
var compileJavaTask = (JavaCompile) task;
compileJavaTask.doFirst(new Action<Task>() {
compileJavaTask.doFirst(new Action<>() {
@Override
public void execute(Task at) {
var t = (JavaCompile) at;
@@ -64,7 +64,7 @@ public void execute(Task at) {
for (var task : project.getTasksByName("compileTestJava", false)) {
if (task instanceof JavaCompile) {
var compileTestJavaTask = (JavaCompile) task;
compileTestJavaTask.doFirst(new Action<Task>() {
compileTestJavaTask.doFirst(new Action<>() {
@Override
public void execute(Task at) {
var t = (JavaCompile) at;
@@ -77,7 +77,7 @@ public void execute(Task at) {
var testSourceDirs = testSourceSet.getAllJava().getSrcDirs().stream().map(File::toString).collect(Collectors.joining(":"));
var classpath = compileTestJavaTask.getClasspath().getAsPath();

var opts = new ArrayList<String>(compileTestJavaTask.getOptions().getCompilerArgs());
var opts = new ArrayList<>(compileTestJavaTask.getOptions().getCompilerArgs());
opts.addAll(List.of(
"--module-path", classpath,
"--patch-module", moduleName + "=" + testSourceDirs
@@ -100,7 +100,7 @@ public void execute(Task at) {
for (var task : project.getTasksByName("test", false)) {
if (task instanceof Test) {
var testTask = (Test) task;
testTask.doFirst(new Action<Task>() {
testTask.doFirst(new Action<>() {
@Override
public void execute(Task at) {
var t = (Test) at;
@@ -113,7 +113,7 @@ public void execute(Task at) {
var outputDir = testSourceSet.getJava().getOutputDir().toString();
var classpath = testTask.getClasspath().getAsPath();

var jvmArgs = new ArrayList<String>(testTask.getJvmArgs());
var jvmArgs = new ArrayList<>(testTask.getJvmArgs());
jvmArgs.addAll(List.of(
"-Djunit.jupiter.extensions.autodetection.enabled=true",
"--module-path", classpath,
@@ -31,7 +31,7 @@ public class Group {
private final String name;
private final String fullName;
private final Contributor lead;
private final Map<String, Contributor> members = new HashMap<String, Contributor>();
private final Map<String, Contributor> members = new HashMap<>();

Group(String name, String fullName, Contributor lead, List<Contributor> members) {
this.name = name;
@@ -32,10 +32,10 @@ public class Project {
private final String fullName;
private final Group sponsor;

private final Map<String, Member> leaders = new HashMap<String, Member>();
private final Map<String, Member> reviewers = new HashMap<String, Member>();
private final Map<String, Member> committers = new HashMap<String, Member>();
private final Map<String, Member> authors = new HashMap<String, Member>();
private final Map<String, Member> leaders = new HashMap<>();
private final Map<String, Member> reviewers = new HashMap<>();
private final Map<String, Member> committers = new HashMap<>();
private final Map<String, Member> authors = new HashMap<>();

private void populate(Map<String, Member> category, List<Member> members) {
for (var member : members) {
@@ -138,7 +138,7 @@ public static void main(String[] args) {
var json = JSON.parse(Files.readString(f));
for (var field : json.fields()) {
var hash = new Hash(field.name());
corrections.put(hash, new HashMap<String, String>());
corrections.put(hash, new HashMap<>());

for (var entry : field.value().fields()) {
var from = entry.name();
@@ -52,14 +52,14 @@ public class GitVerifyImport {

private static <T> void diff(Set<T> hg, Set<T> git, String description) throws IOException {
System.err.println("The following " + description + " are in the git repostiory but not in the hg repository");
var diff = new TreeSet<T>(git);
var diff = new TreeSet<>(git);
diff.removeAll(hg);
for (var e : diff) {
System.err.println(" " + e.toString());
}

System.err.println("The following " + description + " are in the hg repository but not in the git repository");
diff = new TreeSet<T>(hg);
diff = new TreeSet<>(hg);
diff.removeAll(git);
for (var e : diff) {
System.err.println(" " + e.toString());
@@ -41,7 +41,7 @@ public class SkaraDebugHelp {
}

static <T3, T4> Pair<T3, T4> of(T3 e1, T4 e2) {
return new Pair<T3, T4>(e1, e2);
return new Pair<>(e1, e2);
}

T1 first() {
@@ -67,7 +67,7 @@ private static String describe(List<Input> inputs) {
}

private static<T> TreeSet<T> sorted(Set<T> s) {
return new TreeSet<T>(s);
return new TreeSet<>(s);
}

private static void showHelpFor(String command, int indentation) {
@@ -43,7 +43,7 @@ public class GitPrHelp {
}

static <T3, T4> Pair<T3, T4> of(T3 e1, T4 e2) {
return new Pair<T3, T4>(e1, e2);
return new Pair<>(e1, e2);
}

T1 first() {
@@ -78,7 +78,7 @@ private static String describe(List<Input> inputs) {
}

private static<T> TreeSet<T> sorted(Set<T> s) {
return new TreeSet<T>(s);
return new TreeSet<>(s);
}

private static void showHelpFor(String command, int indentation) {
@@ -31,7 +31,7 @@ public Forge create(URI uri, Credential credential, JSONObject configuration) {
webUriReplacement = configuration.get("weburl").get("replacement").asString();
}

Set<String> orgs = new HashSet<String>();
Set<String> orgs = new HashSet<>();
if (configuration != null && configuration.contains("orgs")) {
orgs = configuration.get("orgs")
.stream()
@@ -27,7 +27,7 @@ public Forge create(URI uri, Credential credential, JSONObject configuration) {
if (configuration != null && configuration.contains("name")) {
name = configuration.get("name").asString();
}
Set<String> groups = new HashSet<String>();
Set<String> groups = new HashSet<>();
if (configuration != null && configuration.contains("groups")) {
groups = configuration.get("groups")
.stream()
@@ -54,8 +54,8 @@ public String toString() {

public Section(String name) {
this.name = name;
this.entries = new HashMap<String, INI.Value>();
this.subsections = new HashMap<String, Section>();
this.entries = new HashMap<>();
this.subsections = new HashMap<>();
}

public String name() {
@@ -44,15 +44,15 @@ public class DuplicateIssuesCheck extends CommitCheck {
}

private void populateIssuesToHashesMap() throws IOException {
issuesToHashes = new HashMap<String, List<Hash>>();
issuesToHashes = new HashMap<>();

for (var metadata : repo.commitMetadata()) {
for (var line : metadata.message()) {
var issue = Issue.fromString(line);
if (issue.isPresent()) {
var id = issue.get().id();
if (!issuesToHashes.containsKey(id)) {
issuesToHashes.put(id, new ArrayList<Hash>());
issuesToHashes.put(id, new ArrayList<>());
}
issuesToHashes.get(id).add(metadata.hash());
}
@@ -45,7 +45,7 @@ public class JCheck {
private final List<String> additionalConfiguration;
private final JCheckConfiguration overridingConfiguration;
private final Census overridingCensus;
private final Map<URI, Census> censuses = new HashMap<URI, Census>();
private final Map<URI, Census> censuses = new HashMap<>();
private final Logger log = Logger.getLogger("org.openjdk.skara.jcheck");

JCheck(ReadOnlyRepository repository,
@@ -133,11 +133,11 @@ private Iterator<Issue> checkCommit(Commit commit) {
var finalCensus = census;
var message = parser.parse(commit);
var enabled = conf.checks().enabled(commitChecks);
var iterator = new MapIterator<CommitCheck, Iterator<Issue>>(enabled.iterator(), c -> {
var iterator = new MapIterator<>(enabled.iterator(), c -> {
log.finer("Running commit check '" + c.name() + "' for " + commit.hash().hex());
return c.check(commit, message, conf, finalCensus);
});
return new FlatMapIterator<Issue>(iterator);
return new FlatMapIterator<>(iterator);
}

private Set<CommitCheck> checksForCommit(Commit c) {
@@ -194,16 +194,16 @@ public void close() throws IOException {
}

private Iterator<Issue> commitIssues(Commits commits) {
return new FlatMapIterator<Issue>(
new MapIterator<Commit, Iterator<Issue>>(commits.iterator(), this::checkCommit));
return new FlatMapIterator<>(
new MapIterator<>(commits.iterator(), this::checkCommit));
}

private Iterator<Issue> repositoryIssues() {
var iterator = new MapIterator<RepositoryCheck, Iterator<Issue>>(repositoryChecks.iterator(), c -> {
var iterator = new MapIterator<>(repositoryChecks.iterator(), c -> {
log.finer("Running repository check '" + c.name() + "'");
return c.check(repository);
});
return new FlatMapIterator<Issue>(iterator);
return new FlatMapIterator<>(iterator);
}

private Issues issues() throws IOException {
@@ -212,7 +212,7 @@ private Issues issues() throws IOException {
var repositoryIssues = repositoryIssues();
var commitIssues = commitIssues(commits);

var errors = new ConcatIterator<Issue>(repositoryIssues, commitIssues);
var errors = new ConcatIterator<>(repositoryIssues, commitIssues);
return new Issues(errors, commits);
}

@@ -122,7 +122,7 @@ Iterator<Issue> check(Commit commit, CommitMessage message, JCheckConfiguration
roles.put(reviewer, role);
}

var missing = new HashMap<String, Integer>(requirements);
var missing = new HashMap<>(requirements);
for (var reviewer : reviewers) {
var role = roles.get(reviewer);
if (missing.get(role) == 0) {
@@ -43,8 +43,8 @@ boolean addsHgTag(Commit commit) {
if (patch.target().path().get().endsWith(".hgtags") ||
patch.target().path().get().endsWith(".hgtags-top-repo")) {
for (var hunk : patch.asTextualPatch().hunks()) {
var removed = new HashSet<String>(hunk.source().lines());
var added = new HashSet<String>(hunk.target().lines());
var removed = new HashSet<>(hunk.source().lines());
var added = new HashSet<>(hunk.target().lines());
added.removeAll(removed);
if (added.size() > 0) {
addsHgTagCache.add(commit.hash());