]> git.ktnx.net Git - mobile-ledger.git/blob - app/src/main/java/net/ktnx/mobileledger/db/TemplateHeader.java
6f8e25df384725c28569a9a56a6c54215763c1f4
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / db / TemplateHeader.java
1 /*
2  * Copyright © 2021 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.db;
19
20 import androidx.annotation.NonNull;
21 import androidx.annotation.Nullable;
22 import androidx.room.ColumnInfo;
23 import androidx.room.Entity;
24 import androidx.room.PrimaryKey;
25
26 import net.ktnx.mobileledger.utils.Misc;
27
28 import org.jetbrains.annotations.NotNull;
29
30 @Entity(tableName = "templates")
31 public class TemplateHeader extends TemplateBase {
32     @PrimaryKey(autoGenerate = true)
33     @NonNull
34     private Long id;
35     @ColumnInfo(name = "name")
36     @NonNull
37     private String name;
38     @NonNull
39     @ColumnInfo(name = "regular_expression")
40     private String regularExpression;
41     @ColumnInfo(name = "test_text")
42     private String testText;
43     @ColumnInfo(name = "transaction_description")
44     private String transactionDescription;
45     @ColumnInfo(name = "transaction_description_match_group")
46     private Integer transactionDescriptionMatchGroup;
47     @ColumnInfo(name = "transaction_comment")
48     private String transactionComment;
49     @ColumnInfo(name = "transaction_comment_match_group")
50     private Integer transactionCommentMatchGroup;
51     @ColumnInfo(name = "date_year")
52     private Integer dateYear;
53     @ColumnInfo(name = "date_year_match_group")
54     private Integer dateYearMatchGroup;
55     @ColumnInfo(name = "date_month")
56     private Integer dateMonth;
57     @ColumnInfo(name = "date_month_match_group")
58     private Integer dateMonthMatchGroup;
59     @ColumnInfo(name = "date_day")
60     private Integer dateDay;
61     @ColumnInfo(name = "date_day_match_group")
62     private Integer dateDayMatchGroup;
63     public TemplateHeader(@NotNull Long id, @NonNull String name,
64                           @NonNull String regularExpression) {
65         this.id = id;
66         this.name = name;
67         this.regularExpression = regularExpression;
68     }
69     public TemplateHeader(TemplateHeader origin) {
70         id = origin.id;
71         name = origin.name;
72         regularExpression = origin.regularExpression;
73         testText = origin.testText;
74         transactionDescription = origin.transactionDescription;
75         transactionDescriptionMatchGroup = origin.transactionDescriptionMatchGroup;
76         transactionComment = origin.transactionComment;
77         transactionCommentMatchGroup = origin.transactionCommentMatchGroup;
78         dateYear = origin.dateYear;
79         dateYearMatchGroup = origin.dateYearMatchGroup;
80         dateMonth = origin.dateMonth;
81         dateMonthMatchGroup = origin.dateMonthMatchGroup;
82         dateDay = origin.dateDay;
83         dateDayMatchGroup = origin.dateDayMatchGroup;
84     }
85     public String getTestText() {
86         return testText;
87     }
88     public void setTestText(String testText) {
89         this.testText = testText;
90     }
91     public Integer getTransactionDescriptionMatchGroup() {
92         return transactionDescriptionMatchGroup;
93     }
94     public void setTransactionDescriptionMatchGroup(Integer transactionDescriptionMatchGroup) {
95         this.transactionDescriptionMatchGroup = transactionDescriptionMatchGroup;
96     }
97     public Integer getTransactionCommentMatchGroup() {
98         return transactionCommentMatchGroup;
99     }
100     public void setTransactionCommentMatchGroup(Integer transactionCommentMatchGroup) {
101         this.transactionCommentMatchGroup = transactionCommentMatchGroup;
102     }
103     public Integer getDateYear() {
104         return dateYear;
105     }
106     public void setDateYear(Integer dateYear) {
107         this.dateYear = dateYear;
108     }
109     public Integer getDateMonth() {
110         return dateMonth;
111     }
112     public void setDateMonth(Integer dateMonth) {
113         this.dateMonth = dateMonth;
114     }
115     public Integer getDateDay() {
116         return dateDay;
117     }
118     public void setDateDay(Integer dateDay) {
119         this.dateDay = dateDay;
120     }
121     @NonNull
122     public Long getId() {
123         return id;
124     }
125     public void setId(@NonNull Long id) {
126         this.id = id;
127     }
128     @NonNull
129     public String getName() {
130         return name;
131     }
132     public void setName(@NonNull String name) {
133         this.name = name;
134     }
135     @NonNull
136     public String getRegularExpression() {
137         return regularExpression;
138     }
139     public void setRegularExpression(@NonNull String regularExpression) {
140         this.regularExpression = regularExpression;
141     }
142     public String getTransactionDescription() {
143         return transactionDescription;
144     }
145     public void setTransactionDescription(String transactionDescription) {
146         this.transactionDescription = transactionDescription;
147     }
148     public String getTransactionComment() {
149         return transactionComment;
150     }
151     public void setTransactionComment(String transactionComment) {
152         this.transactionComment = transactionComment;
153     }
154     public Integer getDateYearMatchGroup() {
155         return dateYearMatchGroup;
156     }
157     public void setDateYearMatchGroup(Integer dateYearMatchGroup) {
158         this.dateYearMatchGroup = dateYearMatchGroup;
159     }
160     public Integer getDateMonthMatchGroup() {
161         return dateMonthMatchGroup;
162     }
163     public void setDateMonthMatchGroup(Integer dateMonthMatchGroup) {
164         this.dateMonthMatchGroup = dateMonthMatchGroup;
165     }
166     public Integer getDateDayMatchGroup() {
167         return dateDayMatchGroup;
168     }
169     public void setDateDayMatchGroup(Integer dateDayMatchGroup) {
170         this.dateDayMatchGroup = dateDayMatchGroup;
171     }
172     @Override
173     public boolean equals(@Nullable Object obj) {
174         if (obj == null)
175             return false;
176         if (!(obj instanceof TemplateHeader))
177             return false;
178
179         TemplateHeader o = (TemplateHeader) obj;
180
181         return Misc.equalLongs(id, o.id) && Misc.equalStrings(name, o.name) &&
182                Misc.equalStrings(regularExpression, o.regularExpression) &&
183                Misc.equalStrings(transactionDescription, o.transactionDescription) &&
184                Misc.equalStrings(transactionComment, o.transactionComment) &&
185                Misc.equalIntegers(transactionDescriptionMatchGroup,
186                        o.transactionDescriptionMatchGroup) &&
187                Misc.equalIntegers(transactionCommentMatchGroup, o.transactionCommentMatchGroup) &&
188                Misc.equalIntegers(dateDay, o.dateDay) &&
189                Misc.equalIntegers(dateDayMatchGroup, o.dateDayMatchGroup) &&
190                Misc.equalIntegers(dateMonth, o.dateMonth) &&
191                Misc.equalIntegers(dateMonthMatchGroup, o.dateMonthMatchGroup) &&
192                Misc.equalIntegers(dateYear, o.dateYear) &&
193                Misc.equalIntegers(dateYearMatchGroup, o.dateYearMatchGroup);
194     }
195     public TemplateHeader createDuplicate() {
196         TemplateHeader dup = new TemplateHeader(this);
197         dup.id = null;
198
199         return dup;
200     }
201 }