Add DataSource interface

Add a new DataSource interface that provides the read() method.

Make ChangeDataSource extend this interface.

This will allow additional data source interfaces to be defined
later, for example an account data source that can be used by
a secondary index of user accounts.

Change-Id: I73b1858a5bffb9dbac459f295e04ef4610873d01
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/query/DataSource.java b/gerrit-server/src/main/java/com/google/gerrit/server/query/DataSource.java
new file mode 100644
index 0000000..83cdc80
--- /dev/null
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/query/DataSource.java
@@ -0,0 +1,26 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.server.query;
+
+import com.google.gwtorm.server.OrmException;
+import com.google.gwtorm.server.ResultSet;
+
+public interface DataSource<T> {
+  /** @return an estimate of the number of results from {@link #read()}. */
+  public int getCardinality();
+
+  /** @return read from the database and return the results. */
+  public ResultSet<T> read() throws OrmException;
+}
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/query/change/ChangeDataSource.java b/gerrit-server/src/main/java/com/google/gerrit/server/query/change/ChangeDataSource.java
index ecfd48c..47bf82d 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/query/change/ChangeDataSource.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/query/change/ChangeDataSource.java
@@ -14,16 +14,9 @@
 
 package com.google.gerrit.server.query.change;
 
-import com.google.gwtorm.server.OrmException;
-import com.google.gwtorm.server.ResultSet;
+import com.google.gerrit.server.query.DataSource;
 
-public interface ChangeDataSource {
-  /** @return an estimate of the number of results from {@link #read()}. */
-  public int getCardinality();
-
+public interface ChangeDataSource extends DataSource<ChangeData> {
   /** @return true if all returned ChangeData.hasChange() will be true. */
   public boolean hasChange();
-
-  /** @return read from the database and return the changes. */
-  public abstract ResultSet<ChangeData> read() throws OrmException;
 }