]> git.ktnx.net Git - mobile-ledger.git/blob - app/src/main/java/net/ktnx/mobileledger/LedgerTransaction.java
move DB structure initialization in a sql_0.sql script
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / LedgerTransaction.java
1 package net.ktnx.mobileledger;
2
3 import java.util.ArrayList;
4 import java.util.Iterator;
5 import java.util.List;
6
7 class LedgerTransaction {
8     private String date;
9     private String description;
10     private List<LedgerTransactionItem> items;
11
12     LedgerTransaction(String date, String description) {
13         this.date = date;
14         this.description = description;
15         this.items = new ArrayList<LedgerTransactionItem>();
16     }
17
18     void add_item(LedgerTransactionItem item) {
19         items.add(item);
20     }
21
22     public String getDate() {
23         return date;
24     }
25
26     public void setDate(String date) {
27         this.date = date;
28     }
29
30     public String getDescription() {
31         return description;
32     }
33
34     public void setDescription(String description) {
35         this.description = description;
36     }
37
38     public Iterator<LedgerTransactionItem> getItemsIterator() {
39         return new Iterator<LedgerTransactionItem>() {
40             private int pointer = 0;
41             @Override
42             public boolean hasNext() {
43                 return pointer < items.size();
44             }
45
46             @Override
47             public LedgerTransactionItem next() {
48                 return hasNext() ? items.get(pointer++) : null;
49             }
50         };
51     }
52 }