]> git.ktnx.net Git - mobile-ledger.git/blob - app/src/main/java/net/ktnx/mobileledger/model/Currency.java
more pronounced day/month delimiters in the transaction list
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / model / Currency.java
1 /*
2  * Copyright © 2020 Damyan Ivanov.
3  * This file is part of MoLe.
4  * MoLe 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  * MoLe 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 MoLe. If not, see <https://www.gnu.org/licenses/>.
16  */
17
18 package net.ktnx.mobileledger.model;
19
20 import net.ktnx.mobileledger.utils.Misc;
21
22 public class Currency {
23     private final int id;
24     private String name;
25     private Position position;
26     private boolean hasGap;
27     public Currency(int id, String name) {
28         this.id = id;
29         this.name = name;
30         position = Position.after;
31         hasGap = true;
32     }
33     public Currency(int id, String name, Position position, boolean hasGap) {
34         this.id = id;
35         this.name = name;
36         this.position = position;
37         this.hasGap = hasGap;
38     }
39     static public boolean equal(Currency left, Currency right) {
40         if (left == null) {
41             return right == null;
42         }
43         else
44             return left.equals(right);
45     }
46     static public boolean equal(Currency left, String right) {
47         right = Misc.emptyIsNull(right);
48         if (left == null) {
49             return right == null;
50         }
51         else {
52             String leftName = Misc.emptyIsNull(left.getName());
53             if (leftName == null) {
54                 return right == null;
55             }
56             else
57                 return leftName.equals(right);
58         }
59     }
60     public int getId() {
61         return id;
62     }
63     public String getName() {
64         return name;
65     }
66     public void setName(String name) {
67         this.name = name;
68     }
69     public Position getPosition() {
70         return position;
71     }
72     public void setPosition(Position position) {
73         this.position = position;
74     }
75     public boolean hasGap() {
76         return hasGap;
77     }
78     public void setHasGap(boolean hasGap) {
79         this.hasGap = hasGap;
80     }
81     public enum Position {
82         before, after, unknown, none
83     }
84 }