-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Finish up model package #75
Finish up model package #75
Conversation
Fix some typos, javadocs and import statement issues Update NameContainsKeywordsPredicate to work properly
I think I'm done for now? Hopes everything works. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, just that I think Name and NameContainsKeywordsPredicate classes should also be extended for its use by TravelPlan.
src/main/java/seedu/address/model/commons/NameContainsKeywordsPredicate.java
Outdated
Show resolved
Hide resolved
*/ | ||
public class NameContainsKeywordsPredicate implements Predicate<Activity> { | ||
public class NameContainsKeywordsPredicate implements Predicate<TravelPlanObject> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe here can also implement Predicate, then we can overload the test method with test(TravelPlan tp) as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated it. But I don't know if it works, can help me check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! Added some comments. Let me know if you have further clarifications. Thanks!!
*/ | ||
public class NameContainsKeywordsPredicate implements Predicate<Activity> { | ||
public class NameContainsKeywordsPredicate implements Predicate<Object> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant implements Predicate<TravelPlanObject>, Predicate<TravelPlan>
since a class can implement more than one interfaces.
public boolean test(Object obj) { | ||
if (obj instanceof TravelPlan) { | ||
return keywords.stream() | ||
.anyMatch(keyword -> StringUtil.containsWordIgnoreCase(((TravelPlan) obj).getName().name, keyword)); | ||
} else if (obj instanceof TravelPlanObject) { | ||
return keywords.stream() | ||
.anyMatch(keyword -> | ||
StringUtil.containsWordIgnoreCase(((TravelPlanObject) obj).getName().name, keyword)); | ||
} else { | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for this, 2 separate (overloaded) test methods:
public boolean test(TravelPlan travelPlan)
and public boolean test(TravelPlanObject tpObject)
Don't merge first, I haven't finish yet