]> source.dussan.org Git - jgit.git/commitdiff
Rename PackConstants to PackExt, a typed pack file extension. 46/9746/2
authorColby Ranger <cranger@google.com>
Thu, 17 Jan 2013 23:00:38 +0000 (15:00 -0800)
committerColby Ranger <cranger@google.com>
Thu, 17 Jan 2013 23:14:43 +0000 (15:14 -0800)
PackConstants previously contained string values for the pack and pack
index extension. Change PackConstant to be PackExt, a typed wrapper
around the string pack file extension.

Change-Id: I86ac4db6da8f33aa42d6f37cfcc119e819444318

12 files changed:
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsGarbageCollector.java
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsInserter.java
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsObjDatabase.java
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackCompactor.java
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackDescription.java
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackFile.java
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackParser.java
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsReader.java
org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/InMemoryRepository.java
org.eclipse.jgit/src/org/eclipse/jgit/storage/file/PackFile.java
org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackConstants.java [deleted file]
org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackExt.java [new file with mode: 0644]

index dd01fa3f179deeb7b6f561f710a022e78118204d..4397813036c1c183e2ac1d41f423b6d335f691e0 100644 (file)
@@ -45,8 +45,8 @@ package org.eclipse.jgit.storage.dfs;
 
 import static org.eclipse.jgit.storage.dfs.DfsObjDatabase.PackSource.GC;
 import static org.eclipse.jgit.storage.dfs.DfsObjDatabase.PackSource.UNREACHABLE_GARBAGE;
-import static org.eclipse.jgit.storage.pack.PackConstants.PACK_EXT;
-import static org.eclipse.jgit.storage.pack.PackConstants.PACK_INDEX_EXT;
+import static org.eclipse.jgit.storage.pack.PackExt.PACK;
+import static org.eclipse.jgit.storage.pack.PackExt.INDEX;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -320,25 +320,25 @@ public class DfsGarbageCollector {
                DfsPackDescription pack = repo.getObjectDatabase().newPack(source);
                newPackDesc.add(pack);
 
-               out = objdb.writeFile(pack, PACK_EXT);
+               out = objdb.writeFile(pack, PACK);
                try {
                        pw.writePack(pm, pm, out);
                } finally {
                        out.close();
                }
 
-               out = objdb.writeFile(pack, PACK_INDEX_EXT);
+               out = objdb.writeFile(pack, INDEX);
                try {
                        CountingOutputStream cnt = new CountingOutputStream(out);
                        pw.writeIndex(cnt);
-                       pack.setFileSize(PACK_INDEX_EXT, cnt.getCount());
+                       pack.setFileSize(INDEX, cnt.getCount());
                } finally {
                        out.close();
                }
 
                PackWriter.Statistics stats = pw.getStatistics();
                pack.setPackStats(stats);
-               pack.setFileSize(PACK_EXT, stats.getTotalBytes());
+               pack.setFileSize(PACK, stats.getTotalBytes());
                pack.setObjectCount(stats.getTotalObjects());
                pack.setDeltaCount(stats.getTotalDeltas());
                objectsPacked += stats.getTotalObjects();
index 51872667f18fb4be86c25ec650b7a00e2e42e7e6..90bd444724a3cf980b4d9463d26bddf7f784a01a 100644 (file)
@@ -43,8 +43,8 @@
 
 package org.eclipse.jgit.storage.dfs;
 
-import static org.eclipse.jgit.storage.pack.PackConstants.PACK_EXT;
-import static org.eclipse.jgit.storage.pack.PackConstants.PACK_INDEX_EXT;
+import static org.eclipse.jgit.storage.pack.PackExt.PACK;
+import static org.eclipse.jgit.storage.pack.PackExt.INDEX;
 
 import java.io.EOFException;
 import java.io.IOException;
@@ -153,7 +153,7 @@ public class DfsInserter extends ObjectInserter {
                        throw new IOException();
 
                byte[] packHash = packOut.writePackFooter();
-               packDsc.setFileSize(PACK_EXT, packOut.getCount());
+               packDsc.setFileSize(PACK, packOut.getCount());
                packOut.close();
                packOut = null;
 
@@ -223,7 +223,7 @@ public class DfsInserter extends ObjectInserter {
 
                rollback = true;
                packDsc = db.newPack(DfsObjDatabase.PackSource.INSERT);
-               packOut = new PackStream(db.writeFile(packDsc, PACK_EXT));
+               packOut = new PackStream(db.writeFile(packDsc, PACK));
                packKey = new DfsPackKey();
 
                // Write the header as though it were a single object pack.
@@ -253,14 +253,14 @@ public class DfsInserter extends ObjectInserter {
                        packIndex = PackIndex.read(buf.openInputStream());
                }
 
-               DfsOutputStream os = db.writeFile(pack, PACK_INDEX_EXT);
+               DfsOutputStream os = db.writeFile(pack, INDEX);
                try {
                        CountingOutputStream cnt = new CountingOutputStream(os);
                        if (buf != null)
                                buf.writeTo(cnt, null);
                        else
                                index(cnt, packHash, list);
-                       pack.setFileSize(PACK_INDEX_EXT, cnt.getCount());
+                       pack.setFileSize(INDEX, cnt.getCount());
                } finally {
                        os.close();
                }
index f241894122570a7a272cb23fad3f6c09c732f8b8..316395535e7a9d2c03875a75e84cd08a86089218 100644 (file)
@@ -56,6 +56,7 @@ import java.util.concurrent.atomic.AtomicReference;
 import org.eclipse.jgit.lib.ObjectDatabase;
 import org.eclipse.jgit.lib.ObjectInserter;
 import org.eclipse.jgit.lib.ObjectReader;
+import org.eclipse.jgit.storage.pack.PackExt;
 
 /** Manages objects stored in {@link DfsPackFile} on a storage system. */
 public abstract class DfsObjDatabase extends ObjectDatabase {
@@ -280,7 +281,7 @@ public abstract class DfsObjDatabase extends ObjectDatabase {
         *             the file cannot be opened.
         */
        protected abstract ReadableChannel openFile(
-                       DfsPackDescription desc, String ext)
+                       DfsPackDescription desc, PackExt ext)
                        throws FileNotFoundException, IOException;
 
        /**
@@ -297,7 +298,7 @@ public abstract class DfsObjDatabase extends ObjectDatabase {
         *             the file cannot be opened.
         */
        protected abstract DfsOutputStream writeFile(
-                       DfsPackDescription desc, String ext) throws IOException;
+                       DfsPackDescription desc, PackExt ext) throws IOException;
 
        void addPack(DfsPackFile newPack) throws IOException {
                PackList o, n;
index ff4c320893b9021e1fb602f1f67e8c723eb0aab5..c17c8633f93191f406680eb33bb1f7f0cd078882 100644 (file)
@@ -44,8 +44,8 @@
 package org.eclipse.jgit.storage.dfs;
 
 import static org.eclipse.jgit.storage.dfs.DfsObjDatabase.PackSource.COMPACT;
-import static org.eclipse.jgit.storage.pack.PackConstants.PACK_EXT;
-import static org.eclipse.jgit.storage.pack.PackConstants.PACK_INDEX_EXT;
+import static org.eclipse.jgit.storage.pack.PackExt.PACK;
+import static org.eclipse.jgit.storage.pack.PackExt.INDEX;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -139,7 +139,7 @@ public class DfsPackCompactor {
                DfsObjDatabase objdb = repo.getObjectDatabase();
                for (DfsPackFile pack : objdb.getPacks()) {
                        DfsPackDescription d = pack.getPackDescription();
-                       if (d.getFileSize(PACK_EXT) < autoAddSize)
+                       if (d.getFileSize(PACK) < autoAddSize)
                                add(pack);
                }
                return this;
@@ -285,12 +285,12 @@ public class DfsPackCompactor {
 
        private void writePack(DfsObjDatabase objdb, DfsPackDescription pack,
                        PackWriter pw, ProgressMonitor pm) throws IOException {
-               DfsOutputStream out = objdb.writeFile(pack, PACK_EXT);
+               DfsOutputStream out = objdb.writeFile(pack, PACK);
                try {
                        CountingOutputStream cnt = new CountingOutputStream(out);
                        pw.writePack(pm, pm, cnt);
                        pack.setObjectCount(pw.getObjectCount());
-                       pack.setFileSize(PACK_EXT, cnt.getCount());
+                       pack.setFileSize(PACK, cnt.getCount());
                } finally {
                        out.close();
                }
@@ -298,11 +298,11 @@ public class DfsPackCompactor {
 
        private void writeIndex(DfsObjDatabase objdb, DfsPackDescription pack,
                        PackWriter pw) throws IOException {
-               DfsOutputStream out = objdb.writeFile(pack, PACK_INDEX_EXT);
+               DfsOutputStream out = objdb.writeFile(pack, INDEX);
                try {
                        CountingOutputStream cnt = new CountingOutputStream(out);
                        pw.writeIndex(cnt);
-                       pack.setFileSize(PACK_INDEX_EXT, cnt.getCount());
+                       pack.setFileSize(INDEX, cnt.getCount());
                } finally {
                        out.close();
                }
index 9cb29af5d29ecf3ecb98f3cb32f0acb01a5a9da6..3d3d80de9312bd6eae48e416ecca3499f6764970 100644 (file)
@@ -49,7 +49,7 @@ import java.util.Set;
 
 import org.eclipse.jgit.lib.ObjectId;
 import org.eclipse.jgit.storage.dfs.DfsObjDatabase.PackSource;
-import org.eclipse.jgit.storage.pack.PackConstants;
+import org.eclipse.jgit.storage.pack.PackExt;
 import org.eclipse.jgit.storage.pack.PackWriter;
 
 /**
@@ -69,7 +69,7 @@ public class DfsPackDescription implements Comparable<DfsPackDescription> {
 
        private long lastModified;
 
-       private Map<String, Long> sizeMap;
+       private Map<PackExt, Long> sizeMap;
 
        private long objectCount;
 
@@ -98,7 +98,7 @@ public class DfsPackDescription implements Comparable<DfsPackDescription> {
                this.repoDesc = repoDesc;
                int dot = name.lastIndexOf('.');
                this.packName = (dot < 0) ? name : name.substring(0, dot);
-               this.sizeMap = new HashMap<String, Long>(5);
+               this.sizeMap = new HashMap<PackExt, Long>(5);
        }
 
        /** @return description of the repository. */
@@ -111,8 +111,8 @@ public class DfsPackDescription implements Comparable<DfsPackDescription> {
         *            the file extension
         * @return name of the file.
         * */
-       public String getFileName(String ext) {
-               return packName + '.' + ext;
+       public String getFileName(PackExt ext) {
+               return packName + '.' + ext.getExtension();
        }
 
        /** @return the source of the pack. */
@@ -153,7 +153,7 @@ public class DfsPackDescription implements Comparable<DfsPackDescription> {
         *            be determined on first read.
         * @return {@code this}
         */
-       public DfsPackDescription setFileSize(String ext, long bytes) {
+       public DfsPackDescription setFileSize(PackExt ext, long bytes) {
                sizeMap.put(ext, Long.valueOf(Math.max(0, bytes)));
                return this;
        }
@@ -163,7 +163,7 @@ public class DfsPackDescription implements Comparable<DfsPackDescription> {
         *            the file extension.
         * @return size of the file, in bytes. If 0 the file size is not yet known.
         */
-       public long getFileSize(String ext) {
+       public long getFileSize(PackExt ext) {
                Long size = sizeMap.get(ext);
                return size == null ? 0 : size.longValue();
        }
@@ -278,6 +278,6 @@ public class DfsPackDescription implements Comparable<DfsPackDescription> {
 
        @Override
        public String toString() {
-               return getFileName(PackConstants.PACK_EXT);
+               return getFileName(PackExt.PACK);
        }
 }
index 4c41557e5dc73b7fc0cd28940ecc5d97e7174b59..ca58f8df21cc73a047c4e1f0e7b1c9f21535a2f8 100644 (file)
@@ -45,8 +45,8 @@
 
 package org.eclipse.jgit.storage.dfs;
 
-import static org.eclipse.jgit.storage.pack.PackConstants.PACK_EXT;
-import static org.eclipse.jgit.storage.pack.PackConstants.PACK_INDEX_EXT;
+import static org.eclipse.jgit.storage.pack.PackExt.PACK;
+import static org.eclipse.jgit.storage.pack.PackExt.INDEX;
 
 import java.io.BufferedInputStream;
 import java.io.EOFException;
@@ -165,7 +165,7 @@ public final class DfsPackFile {
                this.packDesc = desc;
                this.key = key;
 
-               length = desc.getFileSize(PACK_EXT);
+               length = desc.getFileSize(PACK);
                if (length <= 0)
                        length = -1;
        }
@@ -190,7 +190,7 @@ public final class DfsPackFile {
        }
 
        private String getPackName() {
-               return packDesc.getFileName(PACK_EXT);
+               return packDesc.getFileName(PACK);
        }
 
        void setBlockSize(int newSize) {
@@ -232,7 +232,7 @@ public final class DfsPackFile {
 
                        PackIndex idx;
                        try {
-                               ReadableChannel rc = ctx.db.openFile(packDesc, PACK_INDEX_EXT);
+                               ReadableChannel rc = ctx.db.openFile(packDesc, INDEX);
                                try {
                                        InputStream in = Channels.newInputStream(rc);
                                        int wantSize = 8192;
@@ -250,14 +250,14 @@ public final class DfsPackFile {
                                invalid = true;
                                IOException e2 = new IOException(MessageFormat.format(
                                                DfsText.get().shortReadOfIndex,
-                                               packDesc.getFileName(PACK_INDEX_EXT)));
+                                               packDesc.getFileName(INDEX)));
                                e2.initCause(e);
                                throw e2;
                        } catch (IOException e) {
                                invalid = true;
                                IOException e2 = new IOException(MessageFormat.format(
                                                DfsText.get().cannotReadIndex,
-                                               packDesc.getFileName(PACK_INDEX_EXT)));
+                                               packDesc.getFileName(INDEX)));
                                e2.initCause(e);
                                throw e2;
                        }
@@ -623,7 +623,7 @@ public final class DfsPackFile {
                        throw new PackInvalidException(getPackName());
 
                boolean close = true;
-               ReadableChannel rc = ctx.db.openFile(packDesc, PACK_EXT);
+               ReadableChannel rc = ctx.db.openFile(packDesc, PACK);
                try {
                        // If the block alignment is not yet known, discover it. Prefer the
                        // larger size from either the cache or the file itself.
index 5956f6448ebdc9e83d97bdccc99e4a651beed3d0..e31de5375f0feddf5cc6c934486136289792ea5b 100644 (file)
@@ -43,7 +43,7 @@
 
 package org.eclipse.jgit.storage.dfs;
 
-import static org.eclipse.jgit.storage.pack.PackConstants.PACK_EXT;
+import static org.eclipse.jgit.storage.pack.PackExt.PACK;
 
 import java.io.EOFException;
 import java.io.IOException;
@@ -148,7 +148,7 @@ public class DfsPackParser extends PackParser {
                        out = null;
                        currBuf = null;
                        readBlock = null;
-                       packDsc.setFileSize(PACK_EXT, packEnd);
+                       packDsc.setFileSize(PACK, packEnd);
 
                        writePackIndex();
                        objdb.commitPack(Collections.singletonList(packDsc), null);
@@ -207,7 +207,7 @@ public class DfsPackParser extends PackParser {
                packDsc = objdb.newPack(DfsObjDatabase.PackSource.RECEIVE);
                packKey = new DfsPackKey();
 
-               out = objdb.writeFile(packDsc, PACK_EXT);
+               out = objdb.writeFile(packDsc, PACK);
                int size = out.blockSize();
                if (size <= 0)
                        size = blockCache.getBlockSize();
index d83137d859315951a8a727cfd8642d4699bb0aa4..393fa3fce2d3b9e28aa4aaa643e130909ebde3ff 100644 (file)
@@ -47,7 +47,7 @@ package org.eclipse.jgit.storage.dfs;
 import static org.eclipse.jgit.lib.Constants.OBJECT_ID_LENGTH;
 import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
 import static org.eclipse.jgit.lib.Constants.OBJ_TREE;
-import static org.eclipse.jgit.storage.pack.PackConstants.PACK_EXT;
+import static org.eclipse.jgit.storage.pack.PackExt.PACK;
 
 import java.io.IOException;
 import java.io.InterruptedIOException;
@@ -662,7 +662,7 @@ public final class DfsReader extends ObjectReader implements ObjectReuseAsIs {
                                pack.setInvalid();
                                throw new IOException(MessageFormat.format(
                                                JGitText.get().packfileCorruptionDetected,
-                                               pack.getPackDescription().getFileName(PACK_EXT)));
+                                               pack.getPackDescription().getFileName(PACK)));
                        }
                }
        }
index 4086539dd3b5f9b79531d9a7529392dc4a7fa9bb..780669df506b7538480bf61a3f6df4d744d250a0 100644 (file)
@@ -15,6 +15,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 
 import org.eclipse.jgit.lib.Ref;
 import org.eclipse.jgit.lib.Ref.Storage;
+import org.eclipse.jgit.storage.pack.PackExt;
 import org.eclipse.jgit.util.RefList;
 
 /**
@@ -103,7 +104,7 @@ public class InMemoryRepository extends DfsRepository {
                }
 
                @Override
-               protected ReadableChannel openFile(DfsPackDescription desc, String ext)
+               protected ReadableChannel openFile(DfsPackDescription desc, PackExt ext)
                                throws FileNotFoundException, IOException {
                        MemPack memPack = (MemPack) desc;
                        byte[] file = memPack.fileMap.get(ext);
@@ -114,7 +115,7 @@ public class InMemoryRepository extends DfsRepository {
 
                @Override
                protected DfsOutputStream writeFile(
-                               DfsPackDescription desc, final String ext) throws IOException {
+                               DfsPackDescription desc, final PackExt ext) throws IOException {
                        final MemPack memPack = (MemPack) desc;
                        return new Out() {
                                @Override
@@ -126,8 +127,8 @@ public class InMemoryRepository extends DfsRepository {
        }
 
        private static class MemPack extends DfsPackDescription {
-               private final Map<String, byte[]>
-                               fileMap = new HashMap<String, byte[]>();
+               private final Map<PackExt, byte[]>
+                               fileMap = new HashMap<PackExt, byte[]>();
 
                MemPack(String name, DfsRepositoryDescription repoDesc) {
                        super(repoDesc, name);
index 8ad01e1c5c74faacf140893887ec7d99049487c2..666df58bec0d6466b1240e47bd0ae30af8d61e22 100644 (file)
@@ -45,7 +45,7 @@
 
 package org.eclipse.jgit.storage.file;
 
-import static org.eclipse.jgit.storage.pack.PackConstants.PACK_INDEX_EXT;
+import static org.eclipse.jgit.storage.pack.PackExt.INDEX;
 
 import java.io.EOFException;
 import java.io.File;
@@ -76,6 +76,7 @@ import org.eclipse.jgit.lib.ObjectId;
 import org.eclipse.jgit.lib.ObjectLoader;
 import org.eclipse.jgit.storage.pack.BinaryDelta;
 import org.eclipse.jgit.storage.pack.ObjectToPack;
+import org.eclipse.jgit.storage.pack.PackExt;
 import org.eclipse.jgit.storage.pack.PackOutputStream;
 import org.eclipse.jgit.util.LongList;
 import org.eclipse.jgit.util.NB;
@@ -155,7 +156,7 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
                                throw new PackInvalidException(packFile);
 
                        try {
-                               final PackIndex idx = PackIndex.open(extFile(PACK_INDEX_EXT));
+                               final PackIndex idx = PackIndex.open(extFile(INDEX));
 
                                if (packChecksum == null)
                                        packChecksum = idx.packChecksum;
@@ -1078,10 +1079,10 @@ public class PackFile implements Iterable<PackIndex.MutableEntry> {
                }
        }
 
-       private File extFile(String ext) {
+       private File extFile(PackExt ext) {
                String p = packFile.getName();
                int dot = p.lastIndexOf('.');
                String b = (dot < 0) ? p : p.substring(0, dot);
-               return new File(packFile.getParentFile(), b + '.' + ext);
+               return new File(packFile.getParentFile(), b + '.' + ext.getExtension());
        }
 }
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackConstants.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackConstants.java
deleted file mode 100644 (file)
index 84acf72..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2013, Google Inc.
- * and other copyright owners as documented in the project's IP log.
- *
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Distribution License v1.0 which
- * accompanies this distribution, is reproduced below, and is
- * available at http://www.eclipse.org/org/documents/edl-v10.php
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- *   copyright notice, this list of conditions and the following
- *   disclaimer in the documentation and/or other materials provided
- *   with the distribution.
- *
- * - Neither the name of the Eclipse Foundation, Inc. nor the
- *   names of its contributors may be used to endorse or promote
- *   products derived from this software without specific prior
- *   written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package org.eclipse.jgit.storage.pack;
-
-/** Misc. constants used with pack files. */
-public class PackConstants {
-
-       /** A pack file extension. */
-       public static final String PACK_EXT = "pack"; //$NON-NLS-1$
-
-       /** A pack index file extension. */
-       public static final String PACK_INDEX_EXT = "idx"; //$NON-NLS-1$
-
-       private PackConstants() {
-       }
-}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackExt.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackExt.java
new file mode 100644 (file)
index 0000000..cb33308
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2013, Google Inc.
+ * and other copyright owners as documented in the project's IP log.
+ *
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Distribution License v1.0 which
+ * accompanies this distribution, is reproduced below, and is
+ * available at http://www.eclipse.org/org/documents/edl-v10.php
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer in the documentation and/or other materials provided
+ *   with the distribution.
+ *
+ * - Neither the name of the Eclipse Foundation, Inc. nor the
+ *   names of its contributors may be used to endorse or promote
+ *   products derived from this software without specific prior
+ *   written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.eclipse.jgit.storage.pack;
+
+/** A pack file extension. */
+public class PackExt {
+
+       /** A pack file extension. */
+       public static final PackExt PACK = new PackExt("pack"); //$NON-NLS-1$
+
+       /** A pack index file extension. */
+       public static final PackExt INDEX = new PackExt("idx"); //$NON-NLS-1$
+
+       private final String ext;
+
+       /**
+        * @param ext
+        *            the file extension.
+        */
+       public PackExt(String ext) {
+               this.ext = ext;
+       }
+
+       /** @return the file extension. */
+       public String getExtension() {
+               return ext;
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (obj instanceof PackExt) {
+                       return ((PackExt) obj).getExtension().equals(getExtension());
+               }
+               return false;
+       }
+
+       @Override
+       public int hashCode() {
+               return getExtension().hashCode();
+       }
+
+       @Override
+       public String toString() {
+               return String.format("PackExt[%s]", getExtension()); //$NON-NLS-1$
+       }
+}