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.Index;
25 import androidx.room.PrimaryKey;
27 import net.ktnx.mobileledger.utils.Misc;
29 import org.jetbrains.annotations.NotNull;
31 @Entity(tableName = "patterns",
32 indices = {@Index(name = "un_patterns_id", value = "id", unique = true)})
33 public class TemplateHeader extends TemplateBase {
34 @PrimaryKey(autoGenerate = true)
37 @ColumnInfo(name = "name")
41 @ColumnInfo(name = "regular_expression")
42 private String regularExpression;
43 @ColumnInfo(name = "test_text")
44 private String testText;
45 @ColumnInfo(name = "transaction_description")
46 private String transactionDescription;
47 @ColumnInfo(name = "transaction_description_match_group")
48 private Integer transactionDescriptionMatchGroup;
49 @ColumnInfo(name = "transaction_comment")
50 private String transactionComment;
51 @ColumnInfo(name = "transaction_comment_match_group")
52 private Integer transactionCommentMatchGroup;
53 @ColumnInfo(name = "date_year")
54 private Integer dateYear;
55 @ColumnInfo(name = "date_year_match_group")
56 private Integer dateYearMatchGroup;
57 @ColumnInfo(name = "date_month")
58 private Integer dateMonth;
59 @ColumnInfo(name = "date_month_match_group")
60 private Integer dateMonthMatchGroup;
61 @ColumnInfo(name = "date_day")
62 private Integer dateDay;
63 @ColumnInfo(name = "date_day_match_group")
64 private Integer dateDayMatchGroup;
65 public TemplateHeader(@NotNull Long id, @NonNull String name,
66 @NonNull String regularExpression) {
69 this.regularExpression = regularExpression;
71 public String getTestText() {
74 public void setTestText(String testText) {
75 this.testText = testText;
77 public Integer getTransactionDescriptionMatchGroup() {
78 return transactionDescriptionMatchGroup;
80 public void setTransactionDescriptionMatchGroup(Integer transactionDescriptionMatchGroup) {
81 this.transactionDescriptionMatchGroup = transactionDescriptionMatchGroup;
83 public Integer getTransactionCommentMatchGroup() {
84 return transactionCommentMatchGroup;
86 public void setTransactionCommentMatchGroup(Integer transactionCommentMatchGroup) {
87 this.transactionCommentMatchGroup = transactionCommentMatchGroup;
89 public Integer getDateYear() {
92 public void setDateYear(Integer dateYear) {
93 this.dateYear = dateYear;
95 public Integer getDateMonth() {
98 public void setDateMonth(Integer dateMonth) {
99 this.dateMonth = dateMonth;
101 public Integer getDateDay() {
104 public void setDateDay(Integer dateDay) {
105 this.dateDay = dateDay;
108 public Long getId() {
111 public void setId(@NonNull Long id) {
115 public String getName() {
118 public void setName(@NonNull String name) {
122 public String getRegularExpression() {
123 return regularExpression;
125 public void setRegularExpression(@NonNull String regularExpression) {
126 this.regularExpression = regularExpression;
128 public String getTransactionDescription() {
129 return transactionDescription;
131 public void setTransactionDescription(String transactionDescription) {
132 this.transactionDescription = transactionDescription;
134 public String getTransactionComment() {
135 return transactionComment;
137 public void setTransactionComment(String transactionComment) {
138 this.transactionComment = transactionComment;
140 public Integer getDateYearMatchGroup() {
141 return dateYearMatchGroup;
143 public void setDateYearMatchGroup(Integer dateYearMatchGroup) {
144 this.dateYearMatchGroup = dateYearMatchGroup;
146 public Integer getDateMonthMatchGroup() {
147 return dateMonthMatchGroup;
149 public void setDateMonthMatchGroup(Integer dateMonthMatchGroup) {
150 this.dateMonthMatchGroup = dateMonthMatchGroup;
152 public Integer getDateDayMatchGroup() {
153 return dateDayMatchGroup;
155 public void setDateDayMatchGroup(Integer dateDayMatchGroup) {
156 this.dateDayMatchGroup = dateDayMatchGroup;
159 public boolean equals(@Nullable Object obj) {
162 if (!(obj instanceof TemplateHeader))
165 TemplateHeader o = (TemplateHeader) obj;
167 return Misc.equalLongs(id, o.id) && Misc.equalStrings(name, o.name) &&
168 Misc.equalStrings(regularExpression, o.regularExpression) &&
169 Misc.equalStrings(transactionDescription, o.transactionDescription) &&
170 Misc.equalStrings(transactionComment, o.transactionComment) &&
171 Misc.equalIntegers(transactionDescriptionMatchGroup,
172 o.transactionDescriptionMatchGroup) &&
173 Misc.equalIntegers(transactionCommentMatchGroup, o.transactionCommentMatchGroup) &&
174 Misc.equalIntegers(dateDay, o.dateDay) &&
175 Misc.equalIntegers(dateDayMatchGroup, o.dateDayMatchGroup) &&
176 Misc.equalIntegers(dateMonth, o.dateMonth) &&
177 Misc.equalIntegers(dateMonthMatchGroup, o.dateMonthMatchGroup) &&
178 Misc.equalIntegers(dateYear, o.dateYear) &&
179 Misc.equalIntegers(dateYearMatchGroup, o.dateYearMatchGroup);