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.
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.
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/>.
18 package net.ktnx.mobileledger.db;
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;
26 import net.ktnx.mobileledger.utils.Misc;
28 import org.jetbrains.annotations.NotNull;
30 @Entity(tableName = "templates")
31 public class TemplateHeader extends TemplateBase {
32 @PrimaryKey(autoGenerate = true)
34 @ColumnInfo(name = "name")
38 @ColumnInfo(name = "regular_expression")
39 private String regularExpression;
40 @ColumnInfo(name = "test_text")
41 private String testText;
42 @ColumnInfo(name = "transaction_description")
43 private String transactionDescription;
44 @ColumnInfo(name = "transaction_description_match_group")
45 private Integer transactionDescriptionMatchGroup;
46 @ColumnInfo(name = "transaction_comment")
47 private String transactionComment;
48 @ColumnInfo(name = "transaction_comment_match_group")
49 private Integer transactionCommentMatchGroup;
50 @ColumnInfo(name = "date_year")
51 private Integer dateYear;
52 @ColumnInfo(name = "date_year_match_group")
53 private Integer dateYearMatchGroup;
54 @ColumnInfo(name = "date_month")
55 private Integer dateMonth;
56 @ColumnInfo(name = "date_month_match_group")
57 private Integer dateMonthMatchGroup;
58 @ColumnInfo(name = "date_day")
59 private Integer dateDay;
60 @ColumnInfo(name = "date_day_match_group")
61 private Integer dateDayMatchGroup;
62 @ColumnInfo(name = "is_fallback")
63 private boolean isFallback;
64 public TemplateHeader(@NotNull Long id, @NonNull String name,
65 @NonNull String regularExpression) {
68 this.regularExpression = regularExpression;
70 public TemplateHeader(TemplateHeader origin) {
73 regularExpression = origin.regularExpression;
74 testText = origin.testText;
75 transactionDescription = origin.transactionDescription;
76 transactionDescriptionMatchGroup = origin.transactionDescriptionMatchGroup;
77 transactionComment = origin.transactionComment;
78 transactionCommentMatchGroup = origin.transactionCommentMatchGroup;
79 dateYear = origin.dateYear;
80 dateYearMatchGroup = origin.dateYearMatchGroup;
81 dateMonth = origin.dateMonth;
82 dateMonthMatchGroup = origin.dateMonthMatchGroup;
83 dateDay = origin.dateDay;
84 dateDayMatchGroup = origin.dateDayMatchGroup;
85 isFallback = origin.isFallback;
87 public boolean isFallback() {
90 public void setFallback(boolean fallback) {
91 isFallback = fallback;
93 public String getTestText() {
96 public void setTestText(String testText) {
97 this.testText = testText;
99 public Integer getTransactionDescriptionMatchGroup() {
100 return transactionDescriptionMatchGroup;
102 public void setTransactionDescriptionMatchGroup(Integer transactionDescriptionMatchGroup) {
103 this.transactionDescriptionMatchGroup = transactionDescriptionMatchGroup;
105 public Integer getTransactionCommentMatchGroup() {
106 return transactionCommentMatchGroup;
108 public void setTransactionCommentMatchGroup(Integer transactionCommentMatchGroup) {
109 this.transactionCommentMatchGroup = transactionCommentMatchGroup;
111 public Integer getDateYear() {
114 public void setDateYear(Integer dateYear) {
115 this.dateYear = dateYear;
117 public Integer getDateMonth() {
120 public void setDateMonth(Integer dateMonth) {
121 this.dateMonth = dateMonth;
123 public Integer getDateDay() {
126 public void setDateDay(Integer dateDay) {
127 this.dateDay = dateDay;
129 public long getId() {
132 public void setId(long id) {
136 public String getName() {
139 public void setName(@NonNull String name) {
143 public String getRegularExpression() {
144 return regularExpression;
146 public void setRegularExpression(@NonNull String regularExpression) {
147 this.regularExpression = regularExpression;
149 public String getTransactionDescription() {
150 return transactionDescription;
152 public void setTransactionDescription(String transactionDescription) {
153 this.transactionDescription = transactionDescription;
155 public String getTransactionComment() {
156 return transactionComment;
158 public void setTransactionComment(String transactionComment) {
159 this.transactionComment = transactionComment;
161 public Integer getDateYearMatchGroup() {
162 return dateYearMatchGroup;
164 public void setDateYearMatchGroup(Integer dateYearMatchGroup) {
165 this.dateYearMatchGroup = dateYearMatchGroup;
167 public Integer getDateMonthMatchGroup() {
168 return dateMonthMatchGroup;
170 public void setDateMonthMatchGroup(Integer dateMonthMatchGroup) {
171 this.dateMonthMatchGroup = dateMonthMatchGroup;
173 public Integer getDateDayMatchGroup() {
174 return dateDayMatchGroup;
176 public void setDateDayMatchGroup(Integer dateDayMatchGroup) {
177 this.dateDayMatchGroup = dateDayMatchGroup;
180 public boolean equals(@Nullable Object obj) {
183 if (!(obj instanceof TemplateHeader))
186 TemplateHeader o = (TemplateHeader) obj;
188 return Misc.equalLongs(id, o.id) && Misc.equalStrings(name, o.name) &&
189 Misc.equalStrings(regularExpression, o.regularExpression) &&
190 Misc.equalStrings(transactionDescription, o.transactionDescription) &&
191 Misc.equalStrings(transactionComment, o.transactionComment) &&
192 Misc.equalIntegers(transactionDescriptionMatchGroup,
193 o.transactionDescriptionMatchGroup) &&
194 Misc.equalIntegers(transactionCommentMatchGroup, o.transactionCommentMatchGroup) &&
195 Misc.equalIntegers(dateDay, o.dateDay) &&
196 Misc.equalIntegers(dateDayMatchGroup, o.dateDayMatchGroup) &&
197 Misc.equalIntegers(dateMonth, o.dateMonth) &&
198 Misc.equalIntegers(dateMonthMatchGroup, o.dateMonthMatchGroup) &&
199 Misc.equalIntegers(dateYear, o.dateYear) &&
200 Misc.equalIntegers(dateYearMatchGroup, o.dateYearMatchGroup);
202 public TemplateHeader createDuplicate() {
203 TemplateHeader dup = new TemplateHeader(this);