2 * Copyright (C) 2015 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jcore.database.result;
19 import java.util.Iterator;
20 import java.util.SortedSet;
21 import java.util.TreeSet;
22 import org.mxchange.jcore.BaseFrameworkSystem;
23 import org.mxchange.jcore.database.storage.Storeable;
27 * @author Roland Haeder
29 public class DatabaseResult extends BaseFrameworkSystem implements Result<Storeable> {
31 * Set of all found Storeable instances
33 private final SortedSet<Storeable> result;
38 public DatabaseResult () {
40 this.result = new TreeSet<>();
44 * Given Storeable instance as a query result.
46 * @param storeable An instance of a Storeable class
49 public void add (final Storeable storeable) {
51 this.result.add(storeable);
55 public boolean hasNext () {
56 // Call iterator's method
57 return this.iterator().hasNext();
61 public Iterator<Storeable> iterator () {
62 // Return iterator from result set
63 return this.result.iterator();
67 public Storeable next () {
68 // Call iterator's method
69 return this.iterator().next();
73 public void remove () {
74 // Call iterator's method
75 this.iterator().remove();