diff options
author | Carsten Hammer <carsten.hammer@t-online.de> | 2019-04-06 20:13:26 +0200 |
---|---|---|
committer | Carsten Hammer <carsten.hammer@t-online.de> | 2019-05-16 02:58:43 -0400 |
commit | 84fc5c908d78a5a78f7d00226e066e56b9c6cafe (patch) | |
tree | 2c53d3af07da8bae0fd34ca0fe3dc9dfd215aa44 /org.eclipse.jgit.pgm | |
parent | c33d2bfb9f5d0f407bb736fafe2fa8ff93309e93 (diff) | |
download | jgit-84fc5c908d78a5a78f7d00226e066e56b9c6cafe.tar.gz jgit-84fc5c908d78a5a78f7d00226e066e56b9c6cafe.zip |
Convert to lambda or member reference
Convert anonymous inner classes to lambda expressions or member
references
Bug: 545856
CQ: 19537
Change-Id: I621431c178e8b99316314602f7c66c9a36f9ae98
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.pgm')
5 files changed, 21 insertions, 46 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java index b98bf151a5..dab52f6ce9 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/CommandCatalog.java @@ -52,7 +52,6 @@ import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Comparator; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; @@ -115,12 +114,8 @@ public class CommandCatalog { private static CommandRef[] toSortedArray(Collection<CommandRef> c) { final CommandRef[] r = c.toArray(new CommandRef[0]); - Arrays.sort(r, new Comparator<CommandRef>() { - @Override - public int compare(CommandRef o1, CommandRef o2) { - return o1.getName().compareTo(o2.getName()); - } - }); + Arrays.sort(r, (CommandRef o1, CommandRef o2) -> o1.getName() + .compareTo(o2.getName())); return r; } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java index 319b5e39dc..43826636aa 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java @@ -66,7 +66,6 @@ import org.eclipse.jgit.transport.DaemonService; import org.eclipse.jgit.transport.ReceivePack; import org.eclipse.jgit.transport.resolver.FileResolver; import org.eclipse.jgit.transport.resolver.ReceivePackFactory; -import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException; import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException; import org.eclipse.jgit.util.FS; import org.kohsuke.args4j.Argument; @@ -188,22 +187,17 @@ class Daemon extends TextBuiltin { final ReceivePackFactory<DaemonClient> factory; factory = daemon.getReceivePackFactory(); - daemon.setReceivePackFactory(new ReceivePackFactory<DaemonClient>() { - @Override - public ReceivePack create(DaemonClient req, Repository repo) - throws ServiceNotEnabledException, - ServiceNotAuthorizedException { - ReceivePack rp = factory.create(req, repo); - KetchLeader leader; - try { - leader = leaders.get(repo); - } catch (URISyntaxException err) { - throw new ServiceNotEnabledException( - KetchText.get().invalidFollowerUri, err); - } - rp.setPreReceiveHook(new KetchPreReceive(leader)); - return rp; + daemon.setReceivePackFactory((DaemonClient req, Repository repo) -> { + ReceivePack rp = factory.create(req, repo); + KetchLeader leader; + try { + leader = leaders.get(repo); + } catch (URISyntaxException err) { + throw new ServiceNotEnabledException( + KetchText.get().invalidFollowerUri, err); } + rp.setPreReceiveHook(new KetchPreReceive(leader)); + return rp; }); } } diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java index 2b5af5d7b7..00bbfb788b 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Glog.java @@ -47,7 +47,6 @@ package org.eclipse.jgit.pgm; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; @@ -87,11 +86,8 @@ class Glog extends RevWalkTextBuiltin { final JPanel buttons = new JPanel(new FlowLayout()); final JButton repaint = new JButton(); repaint.setText(CLIText.get().repaint); - repaint.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - graphPane.repaint(); - } + repaint.addActionListener((ActionEvent e) -> { + graphPane.repaint(); }); buttons.add(repaint); diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java index 1c2564dd7c..708fcde683 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java @@ -46,7 +46,6 @@ package org.eclipse.jgit.pgm; import java.io.IOException; -import java.util.Comparator; import java.util.TreeSet; import org.eclipse.jgit.api.Git; @@ -76,13 +75,8 @@ class LsRemote extends TextBuiltin { protected void run() { LsRemoteCommand command = Git.lsRemoteRepository().setRemote(remote) .setTimeout(timeout).setHeads(heads).setTags(tags); - TreeSet<Ref> refs = new TreeSet<>(new Comparator<Ref>() { - - @Override - public int compare(Ref r1, Ref r2) { - return r1.getName().compareTo(r2.getName()); - } - }); + TreeSet<Ref> refs = new TreeSet<>( + (Ref r1, Ref r2) -> r1.getName().compareTo(r2.getName())); try { refs.addAll(command.call()); for (Ref r : refs) { diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java index 6165c0aeed..85a74448f7 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/debug/DiffAlgorithms.java @@ -52,7 +52,6 @@ import java.lang.management.ThreadMXBean; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Collections; -import java.util.Comparator; import java.util.List; import org.eclipse.jgit.diff.DiffAlgorithm; @@ -235,15 +234,12 @@ class DiffAlgorithms extends TextBuiltin { } } - Collections.sort(all, new Comparator<Test>() { - @Override - public int compare(Test a, Test b) { - int result = Long.signum(a.runningTimeNanos - b.runningTimeNanos); - if (result == 0) { - result = a.algorithm.name.compareTo(b.algorithm.name); - } - return result; + Collections.sort(all, (Test a, Test b) -> { + int result = Long.signum(a.runningTimeNanos - b.runningTimeNanos); + if (result == 0) { + result = a.algorithm.name.compareTo(b.algorithm.name); } + return result; }); File directory = repo.getDirectory(); |