From 0a14909bcfd2cc7b6bbfa172a15d305d38ab85f2 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Fri, 11 Apr 2014 14:01:56 -0700 Subject: Make ArchiveFormats final and implement equals() This should make it easier to modify ArchiveCommand to allow an archive format to be registered twice while still noticing if different callers try to register different implementations for the same format. Change-Id: I32261bc8dc1877a853b49e0da0a6e78921791812 Signed-off-by: Jonathan Nieder --- .../src/org/eclipse/jgit/archive/TarFormat.java | 12 +++++++++++- .../src/org/eclipse/jgit/archive/Tbz2Format.java | 12 +++++++++++- .../src/org/eclipse/jgit/archive/TgzFormat.java | 12 +++++++++++- .../src/org/eclipse/jgit/archive/TxzFormat.java | 12 +++++++++++- .../src/org/eclipse/jgit/archive/ZipFormat.java | 12 +++++++++++- 5 files changed, 55 insertions(+), 5 deletions(-) (limited to 'org.eclipse.jgit.archive/src/org') diff --git a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java index c552fb1844..3412476459 100644 --- a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java +++ b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java @@ -61,7 +61,7 @@ import org.eclipse.jgit.lib.ObjectLoader; /** * Unix TAR format (ustar + some PAX extensions). */ -public class TarFormat implements ArchiveCommand.Format { +public final class TarFormat implements ArchiveCommand.Format { private static final List SUFFIXES = Collections .unmodifiableList(Arrays.asList(".tar")); //$NON-NLS-1$ @@ -118,4 +118,14 @@ public class TarFormat implements ArchiveCommand.Format { public Iterable suffixes() { return SUFFIXES; } + + @Override + public boolean equals(Object other) { + return (other instanceof TarFormat); + } + + @Override + public int hashCode() { + return getClass().hashCode(); + } } diff --git a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/Tbz2Format.java b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/Tbz2Format.java index 61aa339b7c..65e1e79642 100644 --- a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/Tbz2Format.java +++ b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/Tbz2Format.java @@ -57,7 +57,7 @@ import org.eclipse.jgit.lib.ObjectLoader; /** * bzip2-compressed tarball (tar.bz2) format. */ -public class Tbz2Format implements ArchiveCommand.Format { +public final class Tbz2Format implements ArchiveCommand.Format { private static final List SUFFIXES = Collections .unmodifiableList(Arrays.asList(".tar.bz2", ".tbz", ".tbz2")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ @@ -78,4 +78,14 @@ public class Tbz2Format implements ArchiveCommand.Format { public Iterable suffixes() { return SUFFIXES; } + + @Override + public boolean equals(Object other) { + return (other instanceof Tbz2Format); + } + + @Override + public int hashCode() { + return getClass().hashCode(); + } } diff --git a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TgzFormat.java b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TgzFormat.java index 534404fad1..e13c88a044 100644 --- a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TgzFormat.java +++ b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TgzFormat.java @@ -57,7 +57,7 @@ import org.eclipse.jgit.lib.ObjectLoader; /** * gzip-compressed tarball (tar.gz) format. */ -public class TgzFormat implements ArchiveCommand.Format { +public final class TgzFormat implements ArchiveCommand.Format { private static final List SUFFIXES = Collections .unmodifiableList(Arrays.asList(".tar.gz", ".tgz")); //$NON-NLS-1$ //$NON-NLS-2$ @@ -78,4 +78,14 @@ public class TgzFormat implements ArchiveCommand.Format { public Iterable suffixes() { return SUFFIXES; } + + @Override + public boolean equals(Object other) { + return (other instanceof TgzFormat); + } + + @Override + public int hashCode() { + return getClass().hashCode(); + } } diff --git a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TxzFormat.java b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TxzFormat.java index f0eed00fd9..d74ca9ba08 100644 --- a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TxzFormat.java +++ b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TxzFormat.java @@ -57,7 +57,7 @@ import org.eclipse.jgit.lib.ObjectLoader; /** * Xz-compressed tar (tar.xz) format. */ -public class TxzFormat implements ArchiveCommand.Format { +public final class TxzFormat implements ArchiveCommand.Format { private static final List SUFFIXES = Collections .unmodifiableList(Arrays.asList(".tar.xz", ".txz")); //$NON-NLS-1$ //$NON-NLS-2$ @@ -78,4 +78,14 @@ public class TxzFormat implements ArchiveCommand.Format { public Iterable suffixes() { return SUFFIXES; } + + @Override + public boolean equals(Object other) { + return (other instanceof TxzFormat); + } + + @Override + public int hashCode() { + return getClass().hashCode(); + } } diff --git a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/ZipFormat.java b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/ZipFormat.java index a2bfbeeb16..e58c7e910b 100644 --- a/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/ZipFormat.java +++ b/org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/ZipFormat.java @@ -60,7 +60,7 @@ import org.eclipse.jgit.lib.ObjectLoader; /** * PKWARE's ZIP format. */ -public class ZipFormat implements ArchiveCommand.Format { +public final class ZipFormat implements ArchiveCommand.Format { private static final List SUFFIXES = Collections .unmodifiableList(Arrays.asList(".zip")); //$NON-NLS-1$ @@ -105,4 +105,14 @@ public class ZipFormat implements ArchiveCommand.Format { public Iterable suffixes() { return SUFFIXES; } + + @Override + public boolean equals(Object other) { + return (other instanceof ZipFormat); + } + + @Override + public int hashCode() { + return getClass().hashCode(); + } } -- cgit v1.2.3