]> 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.PrimaryKey;
25
26 import net.ktnx.mobileledger.utils.Misc;
27
28 import org.jetbrains.annotations.NotNull;
29
30 @Entity(tableName = "templates")
31 public class TemplateHeader extends TemplateBase {
32     @PrimaryKey(autoGenerate = true)
33     @NonNull
34     private Long id;
35     @ColumnInfo(name = "name")
36     @NonNull
37     private String name;
38     @NonNull
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) {
65         this.id = id;
66         this.name = name;
67         this.regularExpression = regularExpression;
68     }
69     public String getTestText() {
70         return testText;
71     }
72     public void setTestText(String testText) {
73         this.testText = testText;
74     }
75     public Integer getTransactionDescriptionMatchGroup() {
76         return transactionDescriptionMatchGroup;
77     }
78     public void setTransactionDescriptionMatchGroup(Integer transactionDescriptionMatchGroup) {
79         this.transactionDescriptionMatchGroup = transactionDescriptionMatchGroup;
80     }
81     public Integer getTransactionCommentMatchGroup() {
82         return transactionCommentMatchGroup;
83     }
84     public void setTransactionCommentMatchGroup(Integer transactionCommentMatchGroup) {
85         this.transactionCommentMatchGroup = transactionCommentMatchGroup;
86     }
87     public Integer getDateYear() {
88         return dateYear;
89     }
90     public void setDateYear(Integer dateYear) {
91         this.dateYear = dateYear;
92     }
93     public Integer getDateMonth() {
94         return dateMonth;
95     }
96     public void setDateMonth(Integer dateMonth) {
97         this.dateMonth = dateMonth;
98     }
99     public Integer getDateDay() {
100         return dateDay;
101     }
102     public void setDateDay(Integer dateDay) {
103         this.dateDay = dateDay;
104     }
105     @NonNull
106     public Long getId() {
107         return id;
108     }
109     public void setId(@NonNull Long id) {
110         this.id = id;
111     }
112     @NonNull
113     public String getName() {
114         return name;
115     }
116     public void setName(@NonNull String name) {
117         this.name = name;
118     }
119     @NonNull
120     public String getRegularExpression() {
121         return regularExpression;
122     }
123     public void setRegularExpression(@NonNull String regularExpression) {
124         this.regularExpression = regularExpression;
125     }
126     public String getTransactionDescription() {
127         return transactionDescription;
128     }
129     public void setTransactionDescription(String transactionDescription) {
130         this.transactionDescription = transactionDescription;
131     }
132     public String getTransactionComment() {
133         return transactionComment;
134     }
135     public void setTransactionComment(String transactionComment) {
136         this.transactionComment = transactionComment;
137     }
138     public Integer getDateYearMatchGroup() {
139         return dateYearMatchGroup;
140     }
141     public void setDateYearMatchGroup(Integer dateYearMatchGroup) {
142         this.dateYearMatchGroup = dateYearMatchGroup;
143     }
144     public Integer getDateMonthMatchGroup() {
145         return dateMonthMatchGroup;
146     }
147     public void setDateMonthMatchGroup(Integer dateMonthMatchGroup) {
148         this.dateMonthMatchGroup = dateMonthMatchGroup;
149     }
150     public Integer getDateDayMatchGroup() {
151         return dateDayMatchGroup;
152     }
153     public void setDateDayMatchGroup(Integer dateDayMatchGroup) {
154         this.dateDayMatchGroup = dateDayMatchGroup;
155     }
156     @Override
157     public boolean equals(@Nullable Object obj) {
158         if (obj == null)
159             return false;
160         if (!(obj instanceof TemplateHeader))
161             return false;
162
163         TemplateHeader o = (TemplateHeader) obj;
164
165         return Misc.equalLongs(id, o.id) && Misc.equalStrings(name, o.name) &&
166                Misc.equalStrings(regularExpression, o.regularExpression) &&
167                Misc.equalStrings(transactionDescription, o.transactionDescription) &&
168                Misc.equalStrings(transactionComment, o.transactionComment) &&
169                Misc.equalIntegers(transactionDescriptionMatchGroup,
170                        o.transactionDescriptionMatchGroup) &&
171                Misc.equalIntegers(transactionCommentMatchGroup, o.transactionCommentMatchGroup) &&
172                Misc.equalIntegers(dateDay, o.dateDay) &&
173                Misc.equalIntegers(dateDayMatchGroup, o.dateDayMatchGroup) &&
174                Misc.equalIntegers(dateMonth, o.dateMonth) &&
175                Misc.equalIntegers(dateMonthMatchGroup, o.dateMonthMatchGroup) &&
176                Misc.equalIntegers(dateYear, o.dateYear) &&
177                Misc.equalIntegers(dateYearMatchGroup, o.dateYearMatchGroup);
178     }
179 }