Skip to content

Commit

Permalink
fix checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
dabzpengu committed Apr 14, 2024
1 parent 8c5f265 commit 0d50cbf
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_SALARY;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;

import java.util.Optional;
import java.util.Set;
import java.util.stream.Stream;

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ public static Tag parseTag(String tag) throws ParseException {
public static InterviewTime parseInterviewTime(String dateTime) throws ParseException {
if (dateTime == null) {
return new InterviewTime(null);
}
else {
} else {
String trimmedDateTime = dateTime.trim();
if (!InterviewTime.isValidInterviewTime(trimmedDateTime)) {
throw new ParseException(InterviewTime.MESSAGE_CONSTRAINTS);
Expand Down
17 changes: 6 additions & 11 deletions src/main/java/seedu/address/model/person/InterviewTime.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package seedu.address.model.person;

import static java.util.Objects.requireNonNull;
import static seedu.address.commons.util.AppUtil.checkArgument;

import java.time.LocalDateTime;
Expand Down Expand Up @@ -34,8 +33,7 @@ public class InterviewTime {
public InterviewTime(String dateTime) {
if (dateTime == null) {
this.dateTime = null;
}
else {
} else {
checkArgument(isValidInterviewTime(dateTime), MESSAGE_CONSTRAINTS);
this.dateTime = LocalDateTime.parse(dateTime, formatter); //set format
}
Expand All @@ -49,13 +47,11 @@ public InterviewTime(String dateTime) {
public static boolean isValidInterviewTime(String test) {
if (test == null) {
return true;
}
else {
} else {
try {
LocalDateTime.parse(test, formatter);
return true;
}
catch (DateTimeParseException e) {
} catch (DateTimeParseException e) {
return false;
}
}
Expand Down Expand Up @@ -97,8 +93,7 @@ public boolean isBefore(InterviewTime date) {
public String toString() {
if (dateTime == null) {
return "No Interviews set";
}
else {
} else {
DateTimeFormatter beautify = DateTimeFormatter.ofPattern("MMMM dd, yyyy hh:mm a", Locale.ENGLISH);
return dateTime.format(beautify);
}
Expand All @@ -116,8 +111,8 @@ public boolean equals(Object other) {
}

InterviewTime otherDateTime = (InterviewTime) other;
return (dateTime == null && otherDateTime.dateTime == null) ||
(dateTime != null && dateTime.equals(otherDateTime.dateTime));
return (dateTime == null && otherDateTime.dateTime == null)
|| (dateTime != null && dateTime.equals(otherDateTime.dateTime));
}

@Override
Expand Down
1 change: 0 additions & 1 deletion src/main/java/seedu/address/model/person/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public Person(
this.email = email;
this.address = address;
this.dateTime = dateTime;
System.out.println("REACHED HERE");
this.salary = salary;
this.info = info;
this.tags.addAll(tags);
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/seedu/address/storage/JsonAdaptedPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ public JsonAdaptedPerson(Person source) {
address = source.getAddress().value;
if (source.getDateTime() == null) {
dateTime = null;
}
else {
} else {
dateTime = source.getDateTime().rawToString();
}
salary = source.getSalary().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.testutil.Assert.assertThrows;

Expand All @@ -12,8 +13,9 @@

public class InterviewTimeTest {
@Test
public void constructor_null_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> new InterviewTime(null));
public void constructor_null_doesNotThrowException() {
InterviewTime interviewTime = new InterviewTime(null);
assertNull(interviewTime.getDateTime());
}

@Test
Expand Down

0 comments on commit 0d50cbf

Please sign in to comment.