[hg] main-silver: RepositoryProvider as interface

  • From: Tomas Stupka < >
  • To:
  • Subject: [hg] main-silver: RepositoryProvider as interface
  • Date: Fri, 11 Oct 2013 11:22:41 -0700

changeset ece268bd2826 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/ece268bd2826
description:
        RepositoryProvider as interface

diffstat:

 bugtracking/src/org/netbeans/modules/bugtracking/jira/JiraUpdater.java       
          |   6 +-
 bugtracking/src/org/netbeans/modules/bugtracking/spi/RepositoryProvider.java 
          |  30 ++++-----
 
bugtracking/src/org/netbeans/modules/bugtracking/team/spi/TeamRepositoryProvider.java
  |   2 +-
 
bugtracking/test/unit/src/org/netbeans/modules/bugtracking/TestRepository.java
         |   5 +
 
bugtracking/test/unit/src/org/netbeans/modules/bugtracking/TestRepositoryProvider.java
 |   8 ++-
 
bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestConnector.java
   |  11 ++-
 
bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestRepository.java
  |   9 ++-
 localtasks/src/org/netbeans/modules/localtasks/RepositoryProviderImpl.java   
          |   8 ++-
 8 files changed, 54 insertions(+), 25 deletions(-)

diffs (292 lines):

diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/jira/JiraUpdater.java 
b/bugtracking/src/org/netbeans/modules/bugtracking/jira/JiraUpdater.java
--- a/bugtracking/src/org/netbeans/modules/bugtracking/jira/JiraUpdater.java
+++ b/bugtracking/src/org/netbeans/modules/bugtracking/jira/JiraUpdater.java
@@ -230,7 +230,7 @@
             throw new UnsupportedOperationException("Not supported yet.");   
   // NOI18N
         }
     }
-    private class JiraProxyRepositoryProvider extends 
RepositoryProvider<Object,Object,Object> {
+    private class JiraProxyRepositoryProvider implements 
RepositoryProvider<Object,Object,Object> {
         @Override
         public Image getIcon(Object r) {
             return null;
@@ -278,6 +278,10 @@
         public Object createIssue(Object r, String summary, String 
description) {
             throw new UnsupportedOperationException("Not supported yet."); 
//To change body of generated methods, choose Tools | Templates.
         }
+        @Override
+        public Collection<Object> getUnsubmittedIssues(Object r) {
+            throw new UnsupportedOperationException("Not supported yet."); 
//To change body of generated methods, choose Tools | Templates.
+        }
     }
 
     private class JiraProxyController implements RepositoryController {
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/spi/RepositoryProvider.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/spi/RepositoryProvider.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/spi/RepositoryProvider.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/spi/RepositoryProvider.java
@@ -57,7 +57,7 @@
  * @param <Q> the implementation specific query type
  * @param <I> the implementation specific issue type
  */
-public abstract class RepositoryProvider<R, Q, I> {
+public interface RepositoryProvider<R, Q, I> {
 
     /**
      * A query from this repository was saved or removed
@@ -75,13 +75,13 @@
      * @param r
      * @return 
      */
-    public abstract RepositoryInfo getInfo(R r);
+    public RepositoryInfo getInfo(R r);
     
     /**
      * Returns the icon for this repository
      * @return
      */
-    public abstract Image getIcon(R r);
+    public Image getIcon(R r);
 
     /**
      * Returns an issue with the given ID
@@ -91,19 +91,19 @@
      * @param id
      * @return
      */
-    public abstract I[] getIssues(R r, String... ids);
+    public I[] getIssues(R r, String... ids);
 
     /**
      * Removes this repository from its connector
      *
      */
-    public abstract void remove(R r);
+    public void remove(R r);
 
     /**
      * Returns the {@link BugtrackignController} for this repository
      * @return
      */
-    public abstract RepositoryController getController(R r);
+    public RepositoryController getController(R r);
 
     /**
      * Creates a new query instance. Might block for a longer time.
@@ -111,7 +111,7 @@
      * @return a new QueryProvider instance or null if it's not possible
      * to access the repository.
      */
-    public abstract Q createQuery(R r); 
+    public Q createQuery(R r); 
 
     /**
      * Creates a new issue instance. Might block for a longer time.
@@ -119,7 +119,7 @@
      * @return return a new issue instance or null if it's not possible
      * to access the repository.
      */
-    public abstract I createIssue(R r);
+    public I createIssue(R r);
 
     /**
      * Creates a new issue instance. Might block for a longer time.
@@ -131,13 +131,13 @@
      * to access the repository.
      * XXX do we need a canCreate(...) if this is provided?
      */
-    public abstract I createIssue(R r, String summary, String description);
+    public I createIssue(R r, String summary, String description);
     
     /**
      * Returns all saved queries
      * @return
      */
-    public abstract Collection<Q> getQueries(R r);
+    public Collection<Q> getQueries(R r);
 
     /**
      * Runs a query against the bugtracking repository to get all issues
@@ -147,22 +147,20 @@
      *
      * @param criteria
      */
-    public abstract Collection<I> simpleSearch(R r, String criteria);
+    public Collection<I> simpleSearch(R r, String criteria);
     
     /**
      * Returns unsubmitted issues for the given repository.
      * @param r repository
      * @return collection of unsubmitted issues
      */
-    public Collection<I> getUnsubmittedIssues (R r) {
-        return Collections.<I>emptyList();
-    }
+    public Collection<I> getUnsubmittedIssues (R r);
     
     /*********
      * EVENTS
      *********/
 
-    public abstract void removePropertyChangeListener(R r, 
PropertyChangeListener listener);
+    public void removePropertyChangeListener(R r, PropertyChangeListener 
listener);
 
-    public abstract void addPropertyChangeListener(R r, 
PropertyChangeListener listener);    
+    public void addPropertyChangeListener(R r, PropertyChangeListener 
listener);    
 }
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/team/spi/TeamRepositoryProvider.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/team/spi/TeamRepositoryProvider.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/team/spi/TeamRepositoryProvider.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/team/spi/TeamRepositoryProvider.java
@@ -47,7 +47,7 @@
  *
  * @author Tomas Stupka
  */
-public abstract class TeamRepositoryProvider<R, Q, I> extends 
RepositoryProvider<R, Q, I> {
+public abstract class TeamRepositoryProvider<R, Q, I> implements 
RepositoryProvider<R, Q, I> {
     public abstract Q getAllIssuesQuery(R repository);
     public abstract Q getMyIssuesQuery(R repository);
     public abstract TeamProject getTeamProject(R repository);
diff --git 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/TestRepository.java
 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/TestRepository.java
--- 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/TestRepository.java
+++ 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/TestRepository.java
@@ -44,6 +44,7 @@
 import java.awt.Image;
 import java.beans.PropertyChangeListener;
 import java.util.Collection;
+import org.netbeans.modules.bugtracking.api.APITestIssue;
 import org.netbeans.modules.bugtracking.spi.RepositoryController;
 import org.netbeans.modules.bugtracking.spi.RepositoryInfo;
 import org.openide.util.Lookup;
@@ -104,4 +105,8 @@
         throw new UnsupportedOperationException("Not supported yet.");
     }
     
+    public Collection<TestIssue> getUnsubmittedIssues(TestRepository r) {
+        throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.
 }
+    
+}
diff --git 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/TestRepositoryProvider.java
 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/TestRepositoryProvider.java
--- 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/TestRepositoryProvider.java
+++ 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/TestRepositoryProvider.java
@@ -53,7 +53,7 @@
  *
  * @author tomas
  */
-public class TestRepositoryProvider extends 
RepositoryProvider<TestRepository, TestQuery, TestIssue> {
+public class TestRepositoryProvider implements 
RepositoryProvider<TestRepository, TestQuery, TestIssue> {
 
     @Override
     public RepositoryInfo getInfo(TestRepository r) {
@@ -114,4 +114,10 @@
     public TestIssue createIssue(TestRepository r, String summary, String 
description) {
         return r.createIssue(summary, description);
     }
+
+    @Override
+    public Collection<TestIssue> getUnsubmittedIssues(TestRepository r) {
+        return r.getUnsubmittedIssues(r);
 }
+     
+}
diff --git 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestConnector.java
 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestConnector.java
--- 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestConnector.java
+++ 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestConnector.java
@@ -202,7 +202,7 @@
 
     }
 
-    public static class APITestRepositoryProvider extends 
RepositoryProvider<APITestRepository, APITestQuery, APITestIssue> {
+    public static class APITestRepositoryProvider implements 
RepositoryProvider<APITestRepository, APITestQuery, APITestIssue> {
 
         @Override
         public RepositoryInfo getInfo(APITestRepository r) {
@@ -256,12 +256,17 @@
 
         @Override
         public Collection<APITestIssue> simpleSearch(APITestRepository r, 
String criteria) {
-            throw new UnsupportedOperationException("Not supported yet."); 
//To change body of generated methods, choose Tools | Templates.
+            return r.simpleSearch(criteria);
         }
 
         @Override
         public APITestIssue createIssue(APITestRepository r, String summary, 
String description) {
-            throw new UnsupportedOperationException("Not supported yet."); 
//To change body of generated methods, choose Tools | Templates.
+            return r.createIssue(summary, description);
+        }
+
+        @Override
+        public Collection<APITestIssue> 
getUnsubmittedIssues(APITestRepository r) {
+            return r.getUnsubmittedIssues();
         }
     }
 
diff --git 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestRepository.java
 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestRepository.java
--- 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestRepository.java
+++ 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestRepository.java
@@ -48,6 +48,7 @@
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -140,7 +141,7 @@
     }
 
     @Override
-    public TestIssue createIssue(String summary, String description) {
+    public APITestIssue createIssue(String summary, String description) {
         newIssue = new APITestIssue(null, this, true, summary, description);
         return newIssue;
     }
@@ -165,7 +166,7 @@
         return ret;
     }
 
-    private PropertyChangeSupport support = new PropertyChangeSupport(this);
+    private final PropertyChangeSupport support = new 
PropertyChangeSupport(this);
     @Override
     public void removePropertyChangeListener(PropertyChangeListener 
listener) { 
         support.removePropertyChangeListener(listener);
@@ -184,6 +185,10 @@
         support.firePropertyChange(new PropertyChangeEvent(this, 
Repository.EVENT_ATTRIBUTES_CHANGED, null, null));
     }
 
+    Collection<APITestIssue> getUnsubmittedIssues() {
+        return Collections.EMPTY_LIST;
+    }
+
     class APITestRepositoryController implements RepositoryController {
         String name;
         String url;
diff --git 
a/localtasks/src/org/netbeans/modules/localtasks/RepositoryProviderImpl.java 
b/localtasks/src/org/netbeans/modules/localtasks/RepositoryProviderImpl.java
--- 
a/localtasks/src/org/netbeans/modules/localtasks/RepositoryProviderImpl.java
+++ 
b/localtasks/src/org/netbeans/modules/localtasks/RepositoryProviderImpl.java
@@ -45,6 +45,7 @@
 import java.awt.Image;
 import java.beans.PropertyChangeListener;
 import java.util.Collection;
+import java.util.Collections;
 import org.netbeans.modules.localtasks.task.LocalTask;
 import org.netbeans.modules.bugtracking.spi.RepositoryController;
 import org.netbeans.modules.bugtracking.spi.RepositoryInfo;
@@ -54,7 +55,7 @@
  *
  * @author Ondrej Vrabec
  */
-public class RepositoryProviderImpl extends 
RepositoryProvider<LocalRepository, LocalQuery, LocalTask> {
+public class RepositoryProviderImpl implements 
RepositoryProvider<LocalRepository, LocalQuery, LocalTask> {
 
     @Override
     public RepositoryInfo getInfo (LocalRepository r) {
@@ -116,4 +117,9 @@
         throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.
     }
     
+    @Override
+    public Collection<LocalTask> getUnsubmittedIssues(LocalRepository r) {
+        return Collections.emptyList();
 }
+    
+}

[hg] main-silver: RepositoryProvider as interface

Tomas Stupka 10/11/2013

Project Features

About this Project

ConnectedDeveloper was started in November 2009, is owned by tpavek, and has 66 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close