summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.http.server
diff options
context:
space:
mode:
authorDave Borowitz <dborowitz@google.com>2017-08-02 16:50:57 -0400
committerDave Borowitz <dborowitz@google.com>2017-08-02 16:50:57 -0400
commitcf9662cdfedac2ccefc3c9267357e828cfa3155d (patch)
tree9ff40ba44f47ae7ffc17511105c0e531e67fa217 /org.eclipse.jgit.http.server
parent9e54cbb6934893765f736cec09b7b8307aee66ab (diff)
downloadjgit-cf9662cdfedac2ccefc3c9267357e828cfa3155d.tar.gz
jgit-cf9662cdfedac2ccefc3c9267357e828cfa3155d.zip
Eliminate SectionParser construction boilerplate
Happily, most anonymous SectionParser implementations can be replaced with FooConfig::new, as long as the constructor takes a single Config arg. Many of these, the non-public ones, can in turn be inlined. A few remaining SectionParsers can be lambdas. Change-Id: I3f563e752dfd2007dd3a48d6d313d20e2685943a
Diffstat (limited to 'org.eclipse.jgit.http.server')
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/AsIsFileService.java10
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultReceivePackFactory.java10
-rw-r--r--org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultUploadPackFactory.java10
3 files changed, 3 insertions, 27 deletions
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/AsIsFileService.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/AsIsFileService.java
index 88ad472acb..d20fe9f27a 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/AsIsFileService.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/AsIsFileService.java
@@ -47,7 +47,6 @@ import javax.servlet.http.HttpServletRequest;
import org.eclipse.jgit.http.server.GitServlet;
import org.eclipse.jgit.lib.Config;
-import org.eclipse.jgit.lib.Config.SectionParser;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
@@ -71,13 +70,6 @@ public class AsIsFileService {
}
};
- private static final SectionParser<ServiceConfig> CONFIG = new SectionParser<ServiceConfig>() {
- @Override
- public ServiceConfig parse(final Config cfg) {
- return new ServiceConfig(cfg);
- }
- };
-
private static class ServiceConfig {
final boolean enabled;
@@ -96,7 +88,7 @@ public class AsIsFileService {
* {@code true}.
*/
protected static boolean isEnabled(Repository db) {
- return db.getConfig().get(CONFIG).enabled;
+ return db.getConfig().get(ServiceConfig::new).enabled;
}
/**
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultReceivePackFactory.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultReceivePackFactory.java
index 04e192bcfb..c0ffbb64d7 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultReceivePackFactory.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultReceivePackFactory.java
@@ -46,7 +46,6 @@ package org.eclipse.jgit.http.server.resolver;
import javax.servlet.http.HttpServletRequest;
import org.eclipse.jgit.lib.Config;
-import org.eclipse.jgit.lib.Config.SectionParser;
import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.ReceivePack;
@@ -68,13 +67,6 @@ import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException;
*/
public class DefaultReceivePackFactory implements
ReceivePackFactory<HttpServletRequest> {
- private static final SectionParser<ServiceConfig> CONFIG = new SectionParser<ServiceConfig>() {
- @Override
- public ServiceConfig parse(final Config cfg) {
- return new ServiceConfig(cfg);
- }
- };
-
private static class ServiceConfig {
final boolean set;
@@ -89,7 +81,7 @@ public class DefaultReceivePackFactory implements
@Override
public ReceivePack create(final HttpServletRequest req, final Repository db)
throws ServiceNotEnabledException, ServiceNotAuthorizedException {
- final ServiceConfig cfg = db.getConfig().get(CONFIG);
+ final ServiceConfig cfg = db.getConfig().get(ServiceConfig::new);
String user = req.getRemoteUser();
if (cfg.set) {
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultUploadPackFactory.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultUploadPackFactory.java
index d01e2efca4..642623bdd9 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultUploadPackFactory.java
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/resolver/DefaultUploadPackFactory.java
@@ -46,7 +46,6 @@ package org.eclipse.jgit.http.server.resolver;
import javax.servlet.http.HttpServletRequest;
import org.eclipse.jgit.lib.Config;
-import org.eclipse.jgit.lib.Config.SectionParser;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.UploadPack;
import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException;
@@ -61,13 +60,6 @@ import org.eclipse.jgit.transport.resolver.UploadPackFactory;
*/
public class DefaultUploadPackFactory implements
UploadPackFactory<HttpServletRequest> {
- private static final SectionParser<ServiceConfig> CONFIG = new SectionParser<ServiceConfig>() {
- @Override
- public ServiceConfig parse(final Config cfg) {
- return new ServiceConfig(cfg);
- }
- };
-
private static class ServiceConfig {
final boolean enabled;
@@ -79,7 +71,7 @@ public class DefaultUploadPackFactory implements
@Override
public UploadPack create(final HttpServletRequest req, final Repository db)
throws ServiceNotEnabledException, ServiceNotAuthorizedException {
- if (db.getConfig().get(CONFIG).enabled)
+ if (db.getConfig().get(ServiceConfig::new).enabled)
return new UploadPack(db);
else
throw new ServiceNotEnabledException();