]> source.dussan.org Git - jgit.git/commitdiff
Make ArchiveFormats final and implement equals() 86/24886/1
authorJonathan Nieder <jrn@google.com>
Fri, 11 Apr 2014 21:01:56 +0000 (14:01 -0700)
committerJonathan Nieder <jrn@google.com>
Fri, 11 Apr 2014 21:01:56 +0000 (14:01 -0700)
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 <jrn@google.com>
org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TarFormat.java
org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/Tbz2Format.java
org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TgzFormat.java
org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/TxzFormat.java
org.eclipse.jgit.archive/src/org/eclipse/jgit/archive/ZipFormat.java

index c552fb184456cc287d9c9570ee8aa53eb0f80c01..3412476459f4ba6ecfd38561ad94c8a018d7b144 100644 (file)
@@ -61,7 +61,7 @@ import org.eclipse.jgit.lib.ObjectLoader;
 /**
  * Unix TAR format (ustar + some PAX extensions).
  */
-public class TarFormat implements ArchiveCommand.Format<ArchiveOutputStream> {
+public final class TarFormat implements ArchiveCommand.Format<ArchiveOutputStream> {
        private static final List<String> SUFFIXES = Collections
                        .unmodifiableList(Arrays.asList(".tar")); //$NON-NLS-1$
 
@@ -118,4 +118,14 @@ public class TarFormat implements ArchiveCommand.Format<ArchiveOutputStream> {
        public Iterable<String> suffixes() {
                return SUFFIXES;
        }
+
+       @Override
+       public boolean equals(Object other) {
+               return (other instanceof TarFormat);
+       }
+
+       @Override
+       public int hashCode() {
+               return getClass().hashCode();
+       }
 }
index 61aa339b7cf7c8c187d33b80454b40c4754f9907..65e1e796428fdc8a568b9b28b8936dafad9fc2d8 100644 (file)
@@ -57,7 +57,7 @@ import org.eclipse.jgit.lib.ObjectLoader;
 /**
  * bzip2-compressed tarball (tar.bz2) format.
  */
-public class Tbz2Format implements ArchiveCommand.Format<ArchiveOutputStream> {
+public final class Tbz2Format implements ArchiveCommand.Format<ArchiveOutputStream> {
        private static final List<String> 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<ArchiveOutputStream> {
        public Iterable<String> suffixes() {
                return SUFFIXES;
        }
+
+       @Override
+       public boolean equals(Object other) {
+               return (other instanceof Tbz2Format);
+       }
+
+       @Override
+       public int hashCode() {
+               return getClass().hashCode();
+       }
 }
index 534404fad1b2e1179da967aa66eac8940e4f1ffe..e13c88a044e207961eef52313747edfe847df91d 100644 (file)
@@ -57,7 +57,7 @@ import org.eclipse.jgit.lib.ObjectLoader;
 /**
  * gzip-compressed tarball (tar.gz) format.
  */
-public class TgzFormat implements ArchiveCommand.Format<ArchiveOutputStream> {
+public final class TgzFormat implements ArchiveCommand.Format<ArchiveOutputStream> {
        private static final List<String> SUFFIXES = Collections
                        .unmodifiableList(Arrays.asList(".tar.gz", ".tgz")); //$NON-NLS-1$ //$NON-NLS-2$
 
@@ -78,4 +78,14 @@ public class TgzFormat implements ArchiveCommand.Format<ArchiveOutputStream> {
        public Iterable<String> suffixes() {
                return SUFFIXES;
        }
+
+       @Override
+       public boolean equals(Object other) {
+               return (other instanceof TgzFormat);
+       }
+
+       @Override
+       public int hashCode() {
+               return getClass().hashCode();
+       }
 }
index f0eed00fd9725c1fb07d7fb892f11d991a13eb2e..d74ca9ba0856506d1961632877a59604b986bef5 100644 (file)
@@ -57,7 +57,7 @@ import org.eclipse.jgit.lib.ObjectLoader;
 /**
  * Xz-compressed tar (tar.xz) format.
  */
-public class TxzFormat implements ArchiveCommand.Format<ArchiveOutputStream> {
+public final class TxzFormat implements ArchiveCommand.Format<ArchiveOutputStream> {
        private static final List<String> SUFFIXES = Collections
                        .unmodifiableList(Arrays.asList(".tar.xz", ".txz")); //$NON-NLS-1$ //$NON-NLS-2$
 
@@ -78,4 +78,14 @@ public class TxzFormat implements ArchiveCommand.Format<ArchiveOutputStream> {
        public Iterable<String> suffixes() {
                return SUFFIXES;
        }
+
+       @Override
+       public boolean equals(Object other) {
+               return (other instanceof TxzFormat);
+       }
+
+       @Override
+       public int hashCode() {
+               return getClass().hashCode();
+       }
 }
index a2bfbeeb16e0924d743ce693c4df3fc649f55110..e58c7e910be340022bc76d792dc141eb975bda6b 100644 (file)
@@ -60,7 +60,7 @@ import org.eclipse.jgit.lib.ObjectLoader;
 /**
  * PKWARE's ZIP format.
  */
-public class ZipFormat implements ArchiveCommand.Format<ArchiveOutputStream> {
+public final class ZipFormat implements ArchiveCommand.Format<ArchiveOutputStream> {
        private static final List<String> SUFFIXES = Collections
                        .unmodifiableList(Arrays.asList(".zip")); //$NON-NLS-1$
 
@@ -105,4 +105,14 @@ public class ZipFormat implements ArchiveCommand.Format<ArchiveOutputStream> {
        public Iterable<String> suffixes() {
                return SUFFIXES;
        }
+
+       @Override
+       public boolean equals(Object other) {
+               return (other instanceof ZipFormat);
+       }
+
+       @Override
+       public int hashCode() {
+               return getClass().hashCode();
+       }
 }