]> git.ktnx.net Git - mobile-ledger.git/blob - app/src/main/java/net/ktnx/mobileledger/LedgerTransaction.java
add license boilerplates for authored content
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / LedgerTransaction.java
1 /*
2  * Copyright © 2018 Damyan Ivanov.
3  * This file is part of Mobile-Ledger.
4  * Mobile-Ledger is free software: you can distribute it and/or modify it
5  * under the term of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your opinion), any later version.
8  *
9  * Mobile-Ledger 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 terms for details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Mobile-Ledger. If not, see <https://www.gnu.org/licenses/>.
16  */
17
18 package net.ktnx.mobileledger;
19
20 import java.util.ArrayList;
21 import java.util.Iterator;
22 import java.util.List;
23
24 class LedgerTransaction {
25     private String date;
26     private String description;
27     private List<LedgerTransactionItem> items;
28
29     LedgerTransaction(String date, String description) {
30         this.date = date;
31         this.description = description;
32         this.items = new ArrayList<>();
33     }
34
35     void add_item(LedgerTransactionItem item) {
36         items.add(item);
37     }
38
39     public String getDate() {
40         return date;
41     }
42
43     public void setDate(String date) {
44         this.date = date;
45     }
46
47     public String getDescription() {
48         return description;
49     }
50
51     public void setDescription(String description) {
52         this.description = description;
53     }
54
55     Iterator<LedgerTransactionItem> getItemsIterator() {
56         return new Iterator<LedgerTransactionItem>() {
57             private int pointer = 0;
58             @Override
59             public boolean hasNext() {
60                 return pointer < items.size();
61             }
62
63             @Override
64             public LedgerTransactionItem next() {
65                 return hasNext() ? items.get(pointer++) : null;
66             }
67         };
68     }
69 }