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
This commit is contained in:
committed by
Dave Borowitz
parent
939ad08358
commit
1972dc6961
@@ -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;
|
||||
}
|
||||
@@ -14,16 +14,9 @@
|
||||
|
||||
package com.google.gerrit.server.query.change;
|
||||
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gwtorm.server.ResultSet;
|
||||
|
||||
public interface ChangeDataSource {
|
||||
/** @return an estimate of the number of results from {@link #read()}. */
|
||||
public int getCardinality();
|
||||
import com.google.gerrit.server.query.DataSource;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user