]> git.mxchange.org Git - jcore.git/blob - src/org/mxchange/jcore/database/result/DatabaseResult.java
DatabaseResult is now "basicly finished".
[jcore.git] / src / org / mxchange / jcore / database / result / DatabaseResult.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
3  *
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.
8  *
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.
13  *
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/>.
16  */
17 package org.mxchange.jcore.database.result;
18
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;
24
25 /**
26  * A database result
27  * @author Roland Haeder
28  */
29 public class DatabaseResult extends BaseFrameworkSystem implements Result<Storeable> {
30         /**
31          * Set of all found Storeable instances
32          */
33         private final SortedSet<Storeable> result;
34
35         /**
36          * Default constructor
37          */
38         public DatabaseResult () {
39                 // Init set here
40                 this.result = new TreeSet<>();
41         }
42
43         /**
44          * Given Storeable instance as a query result.
45          *
46          * @param storeable An instance of a Storeable class
47          */
48         @Override
49         public void add (final Storeable storeable) {
50                 // Add to result
51                 this.result.add(storeable);
52         }
53
54         @Override
55         public boolean hasNext () {
56                 // Call iterator's method
57                 return this.iterator().hasNext();
58         }
59
60         @Override
61         public Iterator<Storeable> iterator () {
62                 // Return iterator from result set
63                 return this.result.iterator();
64         }
65
66         @Override
67         public Storeable next () {
68                 // Call iterator's method
69                 return this.iterator().next();
70         }
71
72         @Override
73         public void remove () {
74                 // Call iterator's method
75                 this.iterator().remove();
76         }
77 }