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.
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.
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/>.
18 package net.ktnx.mobileledger;
20 import java.util.ArrayList;
21 import java.util.Iterator;
22 import java.util.List;
24 class LedgerTransaction {
26 private String description;
27 private List<LedgerTransactionItem> items;
29 LedgerTransaction(String date, String description) {
31 this.description = description;
32 this.items = new ArrayList<>();
35 void add_item(LedgerTransactionItem item) {
39 public String getDate() {
43 public void setDate(String date) {
47 public String getDescription() {
51 public void setDescription(String description) {
52 this.description = description;
55 Iterator<LedgerTransactionItem> getItemsIterator() {
56 return new Iterator<LedgerTransactionItem>() {
57 private int pointer = 0;
59 public boolean hasNext() {
60 return pointer < items.size();
64 public LedgerTransactionItem next() {
65 return hasNext() ? items.get(pointer++) : null;