]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/db/PatternHeader.java
rework pattern management machinery
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / db / PatternHeader.java
index e518bb093f453f931aa5338d51051d6b9b513c51..c6223c4f8bbcd54cd4c0171fd54d93d2ffda59f2 100644 (file)
@@ -1,11 +1,14 @@
 package net.ktnx.mobileledger.db;
 
 import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
 import androidx.room.ColumnInfo;
 import androidx.room.Entity;
 import androidx.room.Index;
 import androidx.room.PrimaryKey;
 
+import net.ktnx.mobileledger.utils.Misc;
+
 import org.jetbrains.annotations.NotNull;
 
 @Entity(tableName = "patterns",
@@ -17,12 +20,11 @@ public class PatternHeader extends PatternBase {
     @ColumnInfo(name = "name")
     @NonNull
     private String name;
-    @ColumnInfo(name = "position")
-    @NonNull
-    private Long position;
     @NonNull
     @ColumnInfo(name = "regular_expression")
     private String regularExpression;
+    @ColumnInfo(name = "test_text")
+    private String testText;
     @ColumnInfo(name = "transaction_description")
     private String transactionDescription;
     @ColumnInfo(name = "transaction_description_match_group")
@@ -43,13 +45,18 @@ public class PatternHeader extends PatternBase {
     private Integer dateDay;
     @ColumnInfo(name = "date_day_match_group")
     private Integer dateDayMatchGroup;
-    public PatternHeader(@NotNull Long id, @NonNull String name, @NotNull Long position,
+    public PatternHeader(@NotNull Long id, @NonNull String name,
                          @NonNull String regularExpression) {
         this.id = id;
         this.name = name;
-        this.position = position;
         this.regularExpression = regularExpression;
     }
+    public String getTestText() {
+        return testText;
+    }
+    public void setTestText(String testText) {
+        this.testText = testText;
+    }
     public Integer getTransactionDescriptionMatchGroup() {
         return transactionDescriptionMatchGroup;
     }
@@ -95,13 +102,6 @@ public class PatternHeader extends PatternBase {
         this.name = name;
     }
     @NonNull
-    public Long getPosition() {
-        return position;
-    }
-    public void setPosition(@NonNull Long position) {
-        this.position = position;
-    }
-    @NonNull
     public String getRegularExpression() {
         return regularExpression;
     }
@@ -138,4 +138,27 @@ public class PatternHeader extends PatternBase {
     public void setDateDayMatchGroup(Integer dateDayMatchGroup) {
         this.dateDayMatchGroup = dateDayMatchGroup;
     }
+    @Override
+    public boolean equals(@Nullable Object obj) {
+        if (obj == null)
+            return false;
+        if (!(obj instanceof PatternHeader))
+            return false;
+
+        PatternHeader o = (PatternHeader) obj;
+
+        return Misc.equalLongs(id, o.id) && Misc.equalStrings(name, o.name) &&
+               Misc.equalStrings(regularExpression, o.regularExpression) &&
+               Misc.equalStrings(transactionDescription, o.transactionDescription) &&
+               Misc.equalStrings(transactionComment, o.transactionComment) &&
+               Misc.equalIntegers(transactionDescriptionMatchGroup,
+                       o.transactionDescriptionMatchGroup) &&
+               Misc.equalIntegers(transactionCommentMatchGroup, o.transactionCommentMatchGroup) &&
+               Misc.equalIntegers(dateDay, o.dateDay) &&
+               Misc.equalIntegers(dateDayMatchGroup, o.dateDayMatchGroup) &&
+               Misc.equalIntegers(dateMonth, o.dateMonth) &&
+               Misc.equalIntegers(dateMonthMatchGroup, o.dateMonthMatchGroup) &&
+               Misc.equalIntegers(dateYear, o.dateYear) &&
+               Misc.equalIntegers(dateYearMatchGroup, o.dateYearMatchGroup);
+    }
 }