]> source.dussan.org Git - jgit.git/commitdiff
InMemoryRepository: Use a real Builder class 56/44056/2
authorDave Borowitz <dborowitz@google.com>
Wed, 18 Mar 2015 00:19:00 +0000 (17:19 -0700)
committerDave Borowitz <dborowitz@google.com>
Wed, 18 Mar 2015 14:22:12 +0000 (10:22 -0400)
Change-Id: I161b98a58503415955a21f2720395611f439ce98

org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/InMemoryRepository.java

index 965aa8d8beef38fec2930d7f46374d0f1b94ce96..ae05536de5feccb08b64489a713f22ee73d8fae7 100644 (file)
@@ -34,6 +34,15 @@ import org.eclipse.jgit.util.RefList;
  * is garbage collected. Closing the repository has no impact on its memory.
  */
 public class InMemoryRepository extends DfsRepository {
+       /** Builder for in-memory repositories. */
+       public static class Builder
+                       extends DfsRepositoryBuilder<Builder, InMemoryRepository> {
+               @Override
+               public InMemoryRepository build() throws IOException {
+                       return new InMemoryRepository(this);
+               }
+       }
+
        private static final AtomicInteger packId = new AtomicInteger();
 
        private final DfsObjDatabase objdb;
@@ -48,13 +57,11 @@ public class InMemoryRepository extends DfsRepository {
         * @since 2.0
         */
        public InMemoryRepository(DfsRepositoryDescription repoDesc) {
-               super(new DfsRepositoryBuilder<DfsRepositoryBuilder, InMemoryRepository>() {
-                       @Override
-                       public InMemoryRepository build() throws IOException {
-                               throw new UnsupportedOperationException();
-                       }
-               }.setRepositoryDescription(repoDesc));
+               this(new Builder().setRepositoryDescription(repoDesc));
+       }
 
+       private InMemoryRepository(Builder builder) {
+               super(builder);
                objdb = new MemObjDatabase(this);
                refdb = new MemRefDatabase();
        }