Skip to content

Conversation

@TopMass99
Copy link

Here is my contribution. This is for a school project.
Adds a null object pattern.

@github-actions
Copy link

github-actions bot commented Apr 27, 2025

PR Summary

This PR implements the Null Object pattern. It adds a NullStudent class to handle cases where a student is not found, preventing null pointer exceptions. The Student class in the data-mapper module is modified, and new files are added for the null-objects module.

Changes

File Summary
data-mapper/src/main/java/com/iluwatar/datamapper/Student.java Added a constructor that throws UnsupportedOperationException. This change might be related to the Null Object pattern implementation.
leader-followers/src/main/java/com/iluwatar/leaderfollowers/App.java Added license header to the file. No functional changes were made to the code.
null-objects/EnrolledStudent.java New file. This class represents a student enrolled in a university. It stores the student's name and provides a getter method.
null-objects/Main.java New file. This class demonstrates the Null Object pattern by retrieving students using University.getStudent(). It prints the names of the retrieved students.
null-objects/README.md New file. This README explains the intent, explanation, example, and structure of the Null Object pattern implementation.
null-objects/Student.java New file. This interface defines the common method getName() for Student classes.
null-objects/nullstudent New file. This class implements the Student interface and represents a student who is not enrolled. Its getName() method returns "Not Enrolled in Student Database".

autogenerated by presubmit.ai

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🚨 Pull request needs attention.

Review Summary

Commits Considered (1)
Files Processed (7)
  • data-mapper/src/main/java/com/iluwatar/datamapper/Student.java (2 hunks)
  • leader-followers/src/main/java/com/iluwatar/leaderfollowers/App.java (1 hunk)
  • null-objects/EnrolledStudent.java (1 hunk)
  • null-objects/Main.java (1 hunk)
  • null-objects/README.md (1 hunk)
  • null-objects/Student.java (1 hunk)
  • null-objects/nullstudent (1 hunk)
Actionable Comments (1)
  • null-objects/nullstudent [1-7]

    possible bug: "Missing Interface Implementation"

Skipped Comments (0)

Comment on lines +1 to +7
public class NullStudent implements Student {

@Override
public String getName() {
return "Not Enrolled in Student Database";
}
} No newline at end of file

Choose a reason for hiding this comment

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

The NullStudent class should implement the Student interface to ensure consistent behavior. Currently, it's unclear what interface it's intended to implement.

@TopMass99 TopMass99 closed this Apr 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant