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)
35 @ColumnInfo(name = "name")
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 @ColumnInfo(name = "is_fallback")
64 private boolean isFallback;
65 public TemplateHeader(@NotNull Long id, @NonNull String name,
66 @NonNull String regularExpression) {
69 this.regularExpression = regularExpression;
71 public TemplateHeader(TemplateHeader origin) {
74 regularExpression = origin.regularExpression;
75 testText = origin.testText;
76 transactionDescription = origin.transactionDescription;
77 transactionDescriptionMatchGroup = origin.transactionDescriptionMatchGroup;
78 transactionComment = origin.transactionComment;
79 transactionCommentMatchGroup = origin.transactionCommentMatchGroup;
80 dateYear = origin.dateYear;
81 dateYearMatchGroup = origin.dateYearMatchGroup;
82 dateMonth = origin.dateMonth;
83 dateMonthMatchGroup = origin.dateMonthMatchGroup;
84 dateDay = origin.dateDay;
85 dateDayMatchGroup = origin.dateDayMatchGroup;
86 isFallback = origin.isFallback;
88 public boolean isFallback() {
91 public void setFallback(boolean fallback) {
92 isFallback = fallback;
94 public String getTestText() {
97 public void setTestText(String testText) {
98 this.testText = testText;
100 public Integer getTransactionDescriptionMatchGroup() {
101 return transactionDescriptionMatchGroup;
103 public void setTransactionDescriptionMatchGroup(Integer transactionDescriptionMatchGroup) {
104 this.transactionDescriptionMatchGroup = transactionDescriptionMatchGroup;
106 public Integer getTransactionCommentMatchGroup() {
107 return transactionCommentMatchGroup;
109 public void setTransactionCommentMatchGroup(Integer transactionCommentMatchGroup) {
110 this.transactionCommentMatchGroup = transactionCommentMatchGroup;
112 public Integer getDateYear() {
115 public void setDateYear(Integer dateYear) {
116 this.dateYear = dateYear;
118 public Integer getDateMonth() {
121 public void setDateMonth(Integer dateMonth) {
122 this.dateMonth = dateMonth;
124 public Integer getDateDay() {
127 public void setDateDay(Integer dateDay) {
128 this.dateDay = dateDay;
131 public Long getId() {
134 public void setId(@NonNull Long id) {
138 public String getName() {
141 public void setName(@NonNull String name) {
145 public String getRegularExpression() {
146 return regularExpression;
148 public void setRegularExpression(@NonNull String regularExpression) {
149 this.regularExpression = regularExpression;
151 public String getTransactionDescription() {
152 return transactionDescription;
154 public void setTransactionDescription(String transactionDescription) {
155 this.transactionDescription = transactionDescription;
157 public String getTransactionComment() {
158 return transactionComment;
160 public void setTransactionComment(String transactionComment) {
161 this.transactionComment = transactionComment;
163 public Integer getDateYearMatchGroup() {
164 return dateYearMatchGroup;
166 public void setDateYearMatchGroup(Integer dateYearMatchGroup) {
167 this.dateYearMatchGroup = dateYearMatchGroup;
169 public Integer getDateMonthMatchGroup() {
170 return dateMonthMatchGroup;
172 public void setDateMonthMatchGroup(Integer dateMonthMatchGroup) {
173 this.dateMonthMatchGroup = dateMonthMatchGroup;
175 public Integer getDateDayMatchGroup() {
176 return dateDayMatchGroup;
178 public void setDateDayMatchGroup(Integer dateDayMatchGroup) {
179 this.dateDayMatchGroup = dateDayMatchGroup;
182 public boolean equals(@Nullable Object obj) {
185 if (!(obj instanceof TemplateHeader))
188 TemplateHeader o = (TemplateHeader) obj;
190 return Misc.equalLongs(id, o.id) && Misc.equalStrings(name, o.name) &&
191 Misc.equalStrings(regularExpression, o.regularExpression) &&
192 Misc.equalStrings(transactionDescription, o.transactionDescription) &&
193 Misc.equalStrings(transactionComment, o.transactionComment) &&
194 Misc.equalIntegers(transactionDescriptionMatchGroup,
195 o.transactionDescriptionMatchGroup) &&
196 Misc.equalIntegers(transactionCommentMatchGroup, o.transactionCommentMatchGroup) &&
197 Misc.equalIntegers(dateDay, o.dateDay) &&
198 Misc.equalIntegers(dateDayMatchGroup, o.dateDayMatchGroup) &&
199 Misc.equalIntegers(dateMonth, o.dateMonth) &&
200 Misc.equalIntegers(dateMonthMatchGroup, o.dateMonthMatchGroup) &&
201 Misc.equalIntegers(dateYear, o.dateYear) &&
202 Misc.equalIntegers(dateYearMatchGroup, o.dateYearMatchGroup);
204 public TemplateHeader createDuplicate() {
205 TemplateHeader dup = new TemplateHeader(this);