summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2024-02-20 01:12:55 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2024-02-20 01:17:55 +0100
commitf4f992cdcbcdad677b92e6dc1606bd670937b919 (patch)
treecfb6e65427d7edc4c0c79f4fdb7dec8cbba307d4 /org.eclipse.jgit
parent426d67848a0e739d69f43098f46ee00b34fa7d77 (diff)
downloadjgit-f4f992cdcbcdad677b92e6dc1606bd670937b919.tar.gz
jgit-f4f992cdcbcdad677b92e6dc1606bd670937b919.zip
Add SystemReader.Delegate to reduce boiler-plate code needed to subclass
Original implementation by Han-Wen Nienhuys in Gerrit [1]. [1] https://gerrit-review.googlesource.com/c/gerrit/+/235169 Bug: jgit-24 Change-Id: I745f8c1c07de013a68168b91c2d9962d530d07bf
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java61
1 files changed, 61 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java
index 4a48762710..ed62c71371 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java
@@ -174,6 +174,67 @@ public abstract class SystemReader {
}
}
+ /**
+ * Delegating SystemReader. Reduces boiler-plate code applications need to
+ * implement when overriding only a few of the SystemReader's methods.
+ *
+ * @since 6.9
+ */
+ public static class Delegate extends SystemReader {
+
+ private final SystemReader delegate;
+
+ /**
+ * Create a delegating system reader
+ *
+ * @param delegate
+ * the system reader to delegate to
+ */
+ public Delegate(SystemReader delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public String getHostname() {
+ return delegate.getHostname();
+ }
+
+ @Override
+ public String getenv(String variable) {
+ return delegate.getenv(variable);
+ }
+
+ @Override
+ public String getProperty(String key) {
+ return delegate.getProperty(key);
+ }
+
+ @Override
+ public FileBasedConfig openUserConfig(Config parent, FS fs) {
+ return delegate.openUserConfig(parent, fs);
+ }
+
+ @Override
+ public FileBasedConfig openSystemConfig(Config parent, FS fs) {
+ return delegate.openSystemConfig(parent, fs);
+ }
+
+ @Override
+ public FileBasedConfig openJGitConfig(Config parent, FS fs) {
+ return delegate.openJGitConfig(parent, fs);
+ }
+
+ @Override
+ public long getCurrentTime() {
+ return delegate.getCurrentTime();
+ }
+
+ @Override
+ public int getTimezone(long when) {
+ return delegate.getTimezone(when);
+ }
+ }
+
private static volatile SystemReader INSTANCE = DEFAULT;
/**