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 public TemplateHeader(@NotNull Long id, @NonNull String name,
64 @NonNull String regularExpression) {
67 this.regularExpression = regularExpression;
69 public TemplateHeader(TemplateHeader origin) {
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;
85 public String getTestText() {
88 public void setTestText(String testText) {
89 this.testText = testText;
91 public Integer getTransactionDescriptionMatchGroup() {
92 return transactionDescriptionMatchGroup;
94 public void setTransactionDescriptionMatchGroup(Integer transactionDescriptionMatchGroup) {
95 this.transactionDescriptionMatchGroup = transactionDescriptionMatchGroup;
97 public Integer getTransactionCommentMatchGroup() {
98 return transactionCommentMatchGroup;
100 public void setTransactionCommentMatchGroup(Integer transactionCommentMatchGroup) {
101 this.transactionCommentMatchGroup = transactionCommentMatchGroup;
103 public Integer getDateYear() {
106 public void setDateYear(Integer dateYear) {
107 this.dateYear = dateYear;
109 public Integer getDateMonth() {
112 public void setDateMonth(Integer dateMonth) {
113 this.dateMonth = dateMonth;
115 public Integer getDateDay() {
118 public void setDateDay(Integer dateDay) {
119 this.dateDay = dateDay;
122 public Long getId() {
125 public void setId(@NonNull Long id) {
129 public String getName() {
132 public void setName(@NonNull String name) {
136 public String getRegularExpression() {
137 return regularExpression;
139 public void setRegularExpression(@NonNull String regularExpression) {
140 this.regularExpression = regularExpression;
142 public String getTransactionDescription() {
143 return transactionDescription;
145 public void setTransactionDescription(String transactionDescription) {
146 this.transactionDescription = transactionDescription;
148 public String getTransactionComment() {
149 return transactionComment;
151 public void setTransactionComment(String transactionComment) {
152 this.transactionComment = transactionComment;
154 public Integer getDateYearMatchGroup() {
155 return dateYearMatchGroup;
157 public void setDateYearMatchGroup(Integer dateYearMatchGroup) {
158 this.dateYearMatchGroup = dateYearMatchGroup;
160 public Integer getDateMonthMatchGroup() {
161 return dateMonthMatchGroup;
163 public void setDateMonthMatchGroup(Integer dateMonthMatchGroup) {
164 this.dateMonthMatchGroup = dateMonthMatchGroup;
166 public Integer getDateDayMatchGroup() {
167 return dateDayMatchGroup;
169 public void setDateDayMatchGroup(Integer dateDayMatchGroup) {
170 this.dateDayMatchGroup = dateDayMatchGroup;
173 public boolean equals(@Nullable Object obj) {
176 if (!(obj instanceof TemplateHeader))
179 TemplateHeader o = (TemplateHeader) obj;
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);