Skip to content
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

Merged
merged 2 commits into from
Apr 13, 2024

Conversation

PyromancerBoom
Copy link

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.

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.
Copy link

@hjungwoo01 hjungwoo01 left a 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() {

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);

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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of constants

Copy link

@hjungwoo01 hjungwoo01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hjungwoo01 hjungwoo01 merged commit eb249b0 into AY2324S2-CS2103T-T17-2:master Apr 13, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants