forked from AY2324S1-CS2103-T16-3/tp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add transaction predicate map and support classes
- Loading branch information
1 parent
da4b795
commit 4b4ea49
Showing
4 changed files
with
148 additions
and
50 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
src/main/java/unicash/commons/enums/TransactionProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package unicash.commons.enums; | ||
|
||
/** | ||
* An enum of all available transaction properties. | ||
*/ | ||
public enum TransactionProperty { | ||
AMOUNT, | ||
CATEGORY, | ||
DATETIME, | ||
LOCATION, | ||
NAME, | ||
TYPE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package unicash.commons.util; | ||
|
||
/** | ||
* A Generic Pair class for utility purposes. | ||
* @param <T> type parameter of the first type of {@code Object} to be contained | ||
* @param <U> type parameter of the second type of {@code Object} to be contained | ||
*/ | ||
public class Pair<T,U> { | ||
private T t; | ||
private U u; | ||
|
||
/** | ||
* Creates the pair object. | ||
* @param t The first object | ||
* @param u The second object | ||
*/ | ||
public Pair(T t, U u) { | ||
this.t = t; | ||
this.u = u; | ||
} | ||
|
||
/** | ||
* Returns the first object. | ||
*/ | ||
public T getFirst() { | ||
return t; | ||
} | ||
|
||
/** | ||
* Returns the second object | ||
*/ | ||
public U getSecond() { | ||
return u; | ||
} | ||
|
||
/** | ||
* Sets the first object. | ||
*/ | ||
public void setFirst(T t) { | ||
this.t = t; | ||
} | ||
|
||
/** | ||
* Sets the second object. | ||
*/ | ||
public void setSecond() { | ||
this.u = u; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "[" + t + ", " + u + "]"; | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/unicash/model/transaction/predicates/BooleanPredicatePair.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package unicash.model.transaction.predicates; | ||
|
||
import unicash.commons.util.Pair; | ||
import unicash.model.transaction.Transaction; | ||
|
||
import java.util.function.Predicate; | ||
|
||
/** | ||
* A wrapper class for containing Boolean and TransactionPredicate pairs. | ||
*/ | ||
public class BooleanPredicatePair | ||
extends Pair<Boolean, Predicate<Transaction>> { | ||
|
||
/** | ||
* Creates the transaction predicate pair object. | ||
* | ||
* @param isActive The boolean indicating the status of the predicate | ||
* @param transactionPredicate The transaction property predicate | ||
*/ | ||
public BooleanPredicatePair(Boolean isActive, Predicate<Transaction> transactionPredicate) { | ||
super(isActive, transactionPredicate); | ||
} | ||
|
||
/** | ||
* Creates the transaction predicate pair object with default false value | ||
* | ||
* @param transactionPredicate The transaction property predicate | ||
*/ | ||
public BooleanPredicatePair(Predicate<Transaction> transactionPredicate) { | ||
super(false, transactionPredicate); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters