]> git.ktnx.net Git - mobile-ledger.git/blob - app/src/main/java/net/ktnx/mobileledger/db/PatternHeader.java
guard against ncurrent navigation controller destination being null
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / db / PatternHeader.java
1 package net.ktnx.mobileledger.db;
2
3 import androidx.annotation.NonNull;
4 import androidx.annotation.Nullable;
5 import androidx.room.ColumnInfo;
6 import androidx.room.Entity;
7 import androidx.room.Index;
8 import androidx.room.PrimaryKey;
9
10 import net.ktnx.mobileledger.utils.Misc;
11
12 import org.jetbrains.annotations.NotNull;
13
14 @Entity(tableName = "patterns",
15         indices = {@Index(name = "un_patterns_id", value = "id", unique = true)})
16 public class PatternHeader extends PatternBase {
17     @PrimaryKey(autoGenerate = true)
18     @NonNull
19     private Long id;
20     @ColumnInfo(name = "name")
21     @NonNull
22     private String name;
23     @NonNull
24     @ColumnInfo(name = "regular_expression")
25     private String regularExpression;
26     @ColumnInfo(name = "test_text")
27     private String testText;
28     @ColumnInfo(name = "transaction_description")
29     private String transactionDescription;
30     @ColumnInfo(name = "transaction_description_match_group")
31     private Integer transactionDescriptionMatchGroup;
32     @ColumnInfo(name = "transaction_comment")
33     private String transactionComment;
34     @ColumnInfo(name = "transaction_comment_match_group")
35     private Integer transactionCommentMatchGroup;
36     @ColumnInfo(name = "date_year")
37     private Integer dateYear;
38     @ColumnInfo(name = "date_year_match_group")
39     private Integer dateYearMatchGroup;
40     @ColumnInfo(name = "date_month")
41     private Integer dateMonth;
42     @ColumnInfo(name = "date_month_match_group")
43     private Integer dateMonthMatchGroup;
44     @ColumnInfo(name = "date_day")
45     private Integer dateDay;
46     @ColumnInfo(name = "date_day_match_group")
47     private Integer dateDayMatchGroup;
48     public PatternHeader(@NotNull Long id, @NonNull String name,
49                          @NonNull String regularExpression) {
50         this.id = id;
51         this.name = name;
52         this.regularExpression = regularExpression;
53     }
54     public String getTestText() {
55         return testText;
56     }
57     public void setTestText(String testText) {
58         this.testText = testText;
59     }
60     public Integer getTransactionDescriptionMatchGroup() {
61         return transactionDescriptionMatchGroup;
62     }
63     public void setTransactionDescriptionMatchGroup(Integer transactionDescriptionMatchGroup) {
64         this.transactionDescriptionMatchGroup = transactionDescriptionMatchGroup;
65     }
66     public Integer getTransactionCommentMatchGroup() {
67         return transactionCommentMatchGroup;
68     }
69     public void setTransactionCommentMatchGroup(Integer transactionCommentMatchGroup) {
70         this.transactionCommentMatchGroup = transactionCommentMatchGroup;
71     }
72     public Integer getDateYear() {
73         return dateYear;
74     }
75     public void setDateYear(Integer dateYear) {
76         this.dateYear = dateYear;
77     }
78     public Integer getDateMonth() {
79         return dateMonth;
80     }
81     public void setDateMonth(Integer dateMonth) {
82         this.dateMonth = dateMonth;
83     }
84     public Integer getDateDay() {
85         return dateDay;
86     }
87     public void setDateDay(Integer dateDay) {
88         this.dateDay = dateDay;
89     }
90     @NonNull
91     public Long getId() {
92         return id;
93     }
94     public void setId(@NonNull Long id) {
95         this.id = id;
96     }
97     @NonNull
98     public String getName() {
99         return name;
100     }
101     public void setName(@NonNull String name) {
102         this.name = name;
103     }
104     @NonNull
105     public String getRegularExpression() {
106         return regularExpression;
107     }
108     public void setRegularExpression(@NonNull String regularExpression) {
109         this.regularExpression = regularExpression;
110     }
111     public String getTransactionDescription() {
112         return transactionDescription;
113     }
114     public void setTransactionDescription(String transactionDescription) {
115         this.transactionDescription = transactionDescription;
116     }
117     public String getTransactionComment() {
118         return transactionComment;
119     }
120     public void setTransactionComment(String transactionComment) {
121         this.transactionComment = transactionComment;
122     }
123     public Integer getDateYearMatchGroup() {
124         return dateYearMatchGroup;
125     }
126     public void setDateYearMatchGroup(Integer dateYearMatchGroup) {
127         this.dateYearMatchGroup = dateYearMatchGroup;
128     }
129     public Integer getDateMonthMatchGroup() {
130         return dateMonthMatchGroup;
131     }
132     public void setDateMonthMatchGroup(Integer dateMonthMatchGroup) {
133         this.dateMonthMatchGroup = dateMonthMatchGroup;
134     }
135     public Integer getDateDayMatchGroup() {
136         return dateDayMatchGroup;
137     }
138     public void setDateDayMatchGroup(Integer dateDayMatchGroup) {
139         this.dateDayMatchGroup = dateDayMatchGroup;
140     }
141     @Override
142     public boolean equals(@Nullable Object obj) {
143         if (obj == null)
144             return false;
145         if (!(obj instanceof PatternHeader))
146             return false;
147
148         PatternHeader o = (PatternHeader) obj;
149
150         return Misc.equalLongs(id, o.id) && Misc.equalStrings(name, o.name) &&
151                Misc.equalStrings(regularExpression, o.regularExpression) &&
152                Misc.equalStrings(transactionDescription, o.transactionDescription) &&
153                Misc.equalStrings(transactionComment, o.transactionComment) &&
154                Misc.equalIntegers(transactionDescriptionMatchGroup,
155                        o.transactionDescriptionMatchGroup) &&
156                Misc.equalIntegers(transactionCommentMatchGroup, o.transactionCommentMatchGroup) &&
157                Misc.equalIntegers(dateDay, o.dateDay) &&
158                Misc.equalIntegers(dateDayMatchGroup, o.dateDayMatchGroup) &&
159                Misc.equalIntegers(dateMonth, o.dateMonth) &&
160                Misc.equalIntegers(dateMonthMatchGroup, o.dateMonthMatchGroup) &&
161                Misc.equalIntegers(dateYear, o.dateYear) &&
162                Misc.equalIntegers(dateYearMatchGroup, o.dateYearMatchGroup);
163     }
164 }