-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add duplicate UID check in JSON #152
Add duplicate UID check in JSON #152
Conversation
This commit introduces a new feature where the system checks for duplicate UIDs in the JSON file. If duplicates are found, the system starts with the default template. This is to ensure data integrity and prevent potential issues caused by duplicate UIDs. This feature is crucial for maintaining the uniqueness of UIDs in our system. It prevents the system from processing the same UID twice, which could lead to unexpected behavior or errors. By starting with the default template when duplicates are found, we ensure that the system can continue to function normally while the user investigates the source of the duplicate UIDs.
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.
Looks good to me.
* | ||
* @return true if duplicate UIDs are present, else false | ||
*/ | ||
public boolean hasDuplicateUids() { |
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.
Nice check
@@ -55,6 +63,10 @@ public Optional<ReadOnlyAddressBook> readAddressBook(Path filePath) throws DataL | |||
try { | |||
JsonSerializableAddressBook addressBook = jsonAddressBook.get(); | |||
Integer maxUid = addressBook.getMaxUid(); | |||
if (addressBook.hasDuplicateUids()) { | |||
logger.warning(DUPLICATE_UID_WARNING); |
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.
Nice use of warnings
@@ -7,6 +7,8 @@ | |||
* Todo: Add validation for uid | |||
*/ | |||
public class UniqueId { | |||
public static final Integer DEFAULT_BASE_UID = 100; |
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.
Nice use of constants
src/main/java/seedu/address/storage/JsonSerializableAddressBook.java
Outdated
Show resolved
Hide resolved
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.
LGTM
This commit introduces a new feature where the system checks for duplicate UIDs in the JSON file. If duplicates are found, the system starts with the default template.
This is to ensure data integrity and prevent potential issues caused by duplicate UIDs. This feature is crucial for maintaining the uniqueness of UIDs in our system.
It prevents the system from processing the same UID twice, which could lead to unexpected behavior or errors.
By starting with the default template when duplicates are found, we ensure that the system can continue to function normally while the user investigates the source of the duplicate UIDs.