-
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Remove Lombok @RequiredArgsConstructor and manually implement constructor #3467
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| public class ClubbedTroll { | ||
| private final String name; | ||
| private final int level; | ||
|
|
||
| public ClubbedTroll(String name, int level) { | ||
| this.name = name; | ||
| this.level = level; | ||
| } | ||
|
|
||
| // Other methods... | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,7 +44,7 @@ Sequence diagram | |
| The main class in our Java Iterator Design Pattern example is the `TreasureChest` that contains items. This demonstrates how to implement and use iterators for efficient collection traversal in Java. | ||
|
|
||
| ```java | ||
| public class TreasureChest { | ||
| public class TreasureChest implements Iterable<Item> { //marking Iterable or overriding to get Iterator<Item> | ||
|
|
||
| private final List<Item> items; | ||
|
|
||
|
|
@@ -61,8 +61,8 @@ public class TreasureChest { | |
| new Item(ItemType.WEAPON, "Steel halberd"), | ||
| new Item(ItemType.WEAPON, "Dagger of poison")); | ||
| } | ||
|
|
||
| public Iterator<Item> iterator(ItemType itemType) { | ||
| @Override //method which have to be overriden if this implements Iterable interface in java | ||
| public Iterator<Item> iterator(ItemType itemType) { | ||
| return new TreasureChestItemIterator(this, itemType); | ||
| } | ||
|
Comment on lines
+65
to
67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method signature does not override the Iterable.iterator() contract. Using @OverRide on a method with a parameter will fail to compile. If you want a type-filtered iterator, provide a separate method with a different name (e.g., iteratorByType) and keep a parameterless iterator() for the Iterable interface. |
||
|
|
||
|
|
||
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.
Declares the class as Iterable but the example snippet does not include the required iterator() method with no parameters. Iterable contract requires public Iterator iterator(). The current snippet will not compile as-is.