]> git.ktnx.net Git - mobile-ledger.git/blob - app/src/main/java/net/ktnx/mobileledger/db/TemplateHeader.java
rename patterns to templates
[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.Index;
25 import androidx.room.PrimaryKey;
26
27 import net.ktnx.mobileledger.utils.Misc;
28
29 import org.jetbrains.annotations.NotNull;
30
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)
35     @NonNull
36     private Long id;
37     @ColumnInfo(name = "name")
38     @NonNull
39     private String name;
40     @NonNull
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) {
67         this.id = id;
68         this.name = name;
69         this.regularExpression = regularExpression;
70     }
71     public String getTestText() {
72         return testText;
73     }
74     public void setTestText(String testText) {
75         this.testText = testText;
76     }
77     public Integer getTransactionDescriptionMatchGroup() {
78         return transactionDescriptionMatchGroup;
79     }
80     public void setTransactionDescriptionMatchGroup(Integer transactionDescriptionMatchGroup) {
81         this.transactionDescriptionMatchGroup = transactionDescriptionMatchGroup;
82     }
83     public Integer getTransactionCommentMatchGroup() {
84         return transactionCommentMatchGroup;
85     }
86     public void setTransactionCommentMatchGroup(Integer transactionCommentMatchGroup) {
87         this.transactionCommentMatchGroup = transactionCommentMatchGroup;
88     }
89     public Integer getDateYear() {
90         return dateYear;
91     }
92     public void setDateYear(Integer dateYear) {
93         this.dateYear = dateYear;
94     }
95     public Integer getDateMonth() {
96         return dateMonth;
97     }
98     public void setDateMonth(Integer dateMonth) {
99         this.dateMonth = dateMonth;
100     }
101     public Integer getDateDay() {
102         return dateDay;
103     }
104     public void setDateDay(Integer dateDay) {
105         this.dateDay = dateDay;
106     }
107     @NonNull
108     public Long getId() {
109         return id;
110     }
111     public void setId(@NonNull Long id) {
112         this.id = id;
113     }
114     @NonNull
115     public String getName() {
116         return name;
117     }
118     public void setName(@NonNull String name) {
119         this.name = name;
120     }
121     @NonNull
122     public String getRegularExpression() {
123         return regularExpression;
124     }
125     public void setRegularExpression(@NonNull String regularExpression) {
126         this.regularExpression = regularExpression;
127     }
128     public String getTransactionDescription() {
129         return transactionDescription;
130     }
131     public void setTransactionDescription(String transactionDescription) {
132         this.transactionDescription = transactionDescription;
133     }
134     public String getTransactionComment() {
135         return transactionComment;
136     }
137     public void setTransactionComment(String transactionComment) {
138         this.transactionComment = transactionComment;
139     }
140     public Integer getDateYearMatchGroup() {
141         return dateYearMatchGroup;
142     }
143     public void setDateYearMatchGroup(Integer dateYearMatchGroup) {
144         this.dateYearMatchGroup = dateYearMatchGroup;
145     }
146     public Integer getDateMonthMatchGroup() {
147         return dateMonthMatchGroup;
148     }
149     public void setDateMonthMatchGroup(Integer dateMonthMatchGroup) {
150         this.dateMonthMatchGroup = dateMonthMatchGroup;
151     }
152     public Integer getDateDayMatchGroup() {
153         return dateDayMatchGroup;
154     }
155     public void setDateDayMatchGroup(Integer dateDayMatchGroup) {
156         this.dateDayMatchGroup = dateDayMatchGroup;
157     }
158     @Override
159     public boolean equals(@Nullable Object obj) {
160         if (obj == null)
161             return false;
162         if (!(obj instanceof TemplateHeader))
163             return false;
164
165         TemplateHeader o = (TemplateHeader) obj;
166
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);
180     }
181 }