From 4870a8153f9cbfaa2f06735e3f2883d06a41555d Mon Sep 17 00:00:00 2001 From: Anurag Agarwal Date: Sun, 10 Nov 2019 01:17:48 +0530 Subject: [PATCH 1/3] Reduces checkstyle errors in intercepting-filter --- .../intercepting/filter/AbstractFilter.java | 4 +-- .../intercepting/filter/AddressFilter.java | 3 +- .../com/iluwatar/intercepting/filter/App.java | 29 +++++++++---------- .../iluwatar/intercepting/filter/Client.java | 24 ++++++++------- .../intercepting/filter/ContactFilter.java | 5 ++-- .../intercepting/filter/DepositFilter.java | 5 ++-- .../iluwatar/intercepting/filter/Filter.java | 3 +- .../intercepting/filter/FilterChain.java | 6 ++-- .../intercepting/filter/FilterManager.java | 3 +- .../intercepting/filter/NameFilter.java | 3 +- .../iluwatar/intercepting/filter/Order.java | 11 ++++--- .../intercepting/filter/OrderFilter.java | 3 +- .../iluwatar/intercepting/filter/Target.java | 18 ++++++------ 13 files changed, 56 insertions(+), 61 deletions(-) diff --git a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/AbstractFilter.java b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/AbstractFilter.java index a51bfba6fc50..aa20365f6ada 100644 --- a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/AbstractFilter.java +++ b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/AbstractFilter.java @@ -25,13 +25,13 @@ /** * Base class for order processing filters. Handles chain management. - * */ public abstract class AbstractFilter implements Filter { private Filter next; - public AbstractFilter() {} + public AbstractFilter() { + } public AbstractFilter(Filter next) { this.next = next; diff --git a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/AddressFilter.java b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/AddressFilter.java index 791cb8ea6a47..6b9a15382b8e 100644 --- a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/AddressFilter.java +++ b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/AddressFilter.java @@ -26,9 +26,8 @@ /** * Concrete implementation of filter This filter is responsible for checking/filtering the input in * the address field. - * - * @author joshzambales * + * @author joshzambales */ public class AddressFilter extends AbstractFilter { diff --git a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/App.java b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/App.java index 822fae13fc35..b81f1e229284 100644 --- a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/App.java +++ b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/App.java @@ -24,7 +24,6 @@ package com.iluwatar.intercepting.filter; /** - * * When a request enters a Web application, it often must pass several entrance tests prior to the * main processing stage. For example, - Has the client been authenticated? - Does the client have a * valid session? - Is the client's IP address from a trusted network? - Does the request path @@ -32,28 +31,26 @@ * the browser type of the client? Some of these checks are tests, resulting in a yes or no answer * that determines whether processing will continue. Other checks manipulate the incoming data * stream into a form suitable for processing. - *

- * The classic solution consists of a series of conditional checks, with any failed check aborting - * the request. Nested if/else statements are a standard strategy, but this solution leads to code - * fragility and a copy-and-paste style of programming, because the flow of the filtering and the - * action of the filters is compiled into the application. - *

- * The key to solving this problem in a flexible and unobtrusive manner is to have a simple + * + *

The classic solution consists of a series of conditional checks, with any failed check + * aborting the request. Nested if/else statements are a standard strategy, but this solution leads + * to code fragility and a copy-and-paste style of programming, because the flow of the filtering + * and the action of the filters is compiled into the application. + * + *

The key to solving this problem in a flexible and unobtrusive manner is to have a simple * mechanism for adding and removing processing components, in which each component completes a * specific filtering action. This is the Intercepting Filter pattern in action. - *

- * In this example we check whether the order request is valid through pre-processing done via - * {@link Filter}. Each field has its own corresponding {@link Filter} - *

- * - * @author joshzambales * + *

In this example we check whether the order request is valid through pre-processing done via + * {@link Filter}. Each field has its own corresponding {@link Filter}. + * + * @author joshzambales */ public class App { /** - * Program entry point - * + * Program entry point. + * * @param args command line args */ public static void main(String[] args) { diff --git a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/Client.java b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/Client.java index 109f3ab02ed5..865dbbb381da 100644 --- a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/Client.java +++ b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/Client.java @@ -23,6 +23,9 @@ package com.iluwatar.intercepting.filter; +import java.awt.BorderLayout; +import java.awt.GridLayout; + import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; @@ -32,18 +35,15 @@ import javax.swing.JTextField; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; -import java.awt.BorderLayout; -import java.awt.GridLayout; /** - * The Client class is responsible for handling the input and running them through filters inside the - * {@link FilterManager}. + * The Client class is responsible for handling the input and running them through filters inside + * the {@link FilterManager}. * - * This is where {@link Filter}s come to play as the client pre-processes the request before being displayed in the - * {@link Target}. - * - * @author joshzambales + *

This is where {@link Filter}s come to play as the client pre-processes the request before + * being displayed in the {@link Target}. * + * @author joshzambales */ public class Client extends JFrame { // NOSONAR @@ -57,7 +57,7 @@ public class Client extends JFrame { // NOSONAR private JButton processButton; /** - * Constructor + * Constructor. */ public Client() { super("Client System"); @@ -107,8 +107,10 @@ private void setup() { }); processButton.addActionListener(e -> { - Order order = new Order(jtFields[0].getText(), jtFields[1].getText(), jtAreas[0].getText(), jtFields[2].getText(), - jtAreas[1].getText()); + Order order = + new Order(jtFields[0].getText(), jtFields[1].getText(), jtAreas[0].getText(), jtFields[2] + .getText(), + jtAreas[1].getText()); jl.setText(sendRequest(order)); }); diff --git a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/ContactFilter.java b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/ContactFilter.java index 84425cd72b55..9acdec31966b 100644 --- a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/ContactFilter.java +++ b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/ContactFilter.java @@ -26,10 +26,9 @@ /** * Concrete implementation of filter This filter checks for the contact field in which it checks if * the input consist of numbers and it also checks if the input follows the length constraint (11 - * digits) - * - * @author joshzambales + * digits). * + * @author joshzambales */ public class ContactFilter extends AbstractFilter { diff --git a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/DepositFilter.java b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/DepositFilter.java index e2e68083bbff..e7457c9bec5b 100644 --- a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/DepositFilter.java +++ b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/DepositFilter.java @@ -24,10 +24,9 @@ package com.iluwatar.intercepting.filter; /** - * Concrete implementation of filter This checks for the deposit code - * - * @author joshzambales + * Concrete implementation of filter This checks for the deposit code. * + * @author joshzambales */ public class DepositFilter extends AbstractFilter { diff --git a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/Filter.java b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/Filter.java index 5c9fe325a758..76afdedbded3 100644 --- a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/Filter.java +++ b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/Filter.java @@ -26,9 +26,8 @@ /** * Filters perform certain tasks prior or after execution of request by request handler. In this * case, before the request is handled by the target, the request undergoes through each Filter - * - * @author joshzambales * + * @author joshzambales */ public interface Filter { diff --git a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/FilterChain.java b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/FilterChain.java index bfd88f61d78b..07429ca5f708 100644 --- a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/FilterChain.java +++ b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/FilterChain.java @@ -26,7 +26,7 @@ /** * Filter Chain carries multiple filters and help to execute them in defined order on target. - * + * * @author joshzambales */ public class FilterChain { @@ -35,7 +35,7 @@ public class FilterChain { /** - * Adds filter + * Adds filter. */ public void addFilter(Filter filter) { if (chain == null) { @@ -46,7 +46,7 @@ public void addFilter(Filter filter) { } /** - * Execute filter chain + * Execute filter chain. */ public String execute(Order order) { if (chain != null) { diff --git a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/FilterManager.java b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/FilterManager.java index cef868dcc4b8..e8f3b941faa1 100644 --- a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/FilterManager.java +++ b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/FilterManager.java @@ -25,9 +25,8 @@ /** * Filter Manager manages the filters and {@link FilterChain}. - * - * @author joshzambales * + * @author joshzambales */ public class FilterManager { diff --git a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/NameFilter.java b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/NameFilter.java index d06b24ca9892..95ef54fe1d82 100644 --- a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/NameFilter.java +++ b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/NameFilter.java @@ -26,9 +26,8 @@ /** * Concrete implementation of filter. This filter checks if the input in the Name field is valid. * (alphanumeric) - * - * @author joshzambales * + * @author joshzambales */ public class NameFilter extends AbstractFilter { diff --git a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/Order.java b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/Order.java index 988464aec41a..a75911578161 100644 --- a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/Order.java +++ b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/Order.java @@ -25,7 +25,6 @@ /** * Order class carries the order data. - * */ public class Order { @@ -35,12 +34,16 @@ public class Order { private String depositNumber; private String orderItem; - public Order() {} + public Order() { + } /** - * Constructor + * Constructor. */ - public Order(String name, String contactNumber, String address, String depositNumber, String order) { + public Order( + String name, String contactNumber, String address, + String depositNumber, String order + ) { this.name = name; this.contactNumber = contactNumber; this.address = address; diff --git a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/OrderFilter.java b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/OrderFilter.java index 8669cd2e7d6c..de91386f3f57 100644 --- a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/OrderFilter.java +++ b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/OrderFilter.java @@ -25,9 +25,8 @@ /** * Concrete implementation of filter. This checks for the order field. - * - * @author joshzambales * + * @author joshzambales */ public class OrderFilter extends AbstractFilter { diff --git a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/Target.java b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/Target.java index 415d3b2b645c..9ded355c757a 100644 --- a/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/Target.java +++ b/intercepting-filter/src/main/java/com/iluwatar/intercepting/filter/Target.java @@ -23,6 +23,11 @@ package com.iluwatar.intercepting.filter; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; @@ -32,16 +37,11 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import javax.swing.table.DefaultTableModel; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; /** * This is where the requests are displayed after being validated by filters. - * - * @author mjoshzambales * + * @author mjoshzambales */ public class Target extends JFrame { //NOSONAR @@ -52,14 +52,14 @@ public class Target extends JFrame { //NOSONAR private JButton del; /** - * Constructor + * Constructor. */ public Target() { super("Order System"); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setSize(640, 480); dtm = - new DefaultTableModel(new Object[] {"Name", "Contact Number", "Address", "Deposit Number", + new DefaultTableModel(new Object[]{"Name", "Contact Number", "Address", "Deposit Number", "Order"}, 0); jt = new JTable(dtm); del = new JButton("Delete"); @@ -85,7 +85,7 @@ private void setup() { } public void execute(String[] request) { - dtm.addRow(new Object[] {request[0], request[1], request[2], request[3], request[4]}); + dtm.addRow(new Object[]{request[0], request[1], request[2], request[3], request[4]}); } class DListener implements ActionListener { From c0830a8399bac050c98053e6e3c41e7d34961e2b Mon Sep 17 00:00:00 2001 From: Anurag Agarwal Date: Sun, 10 Nov 2019 01:19:59 +0530 Subject: [PATCH 2/3] Reduces checkstyle errors in interpreter --- .../java/com/iluwatar/interpreter/App.java | 23 ++++++++----------- .../com/iluwatar/interpreter/Expression.java | 4 +--- .../iluwatar/interpreter/MinusExpression.java | 4 +--- .../interpreter/MultiplyExpression.java | 4 +--- .../interpreter/NumberExpression.java | 4 +--- .../iluwatar/interpreter/PlusExpression.java | 4 +--- 6 files changed, 14 insertions(+), 29 deletions(-) diff --git a/interpreter/src/main/java/com/iluwatar/interpreter/App.java b/interpreter/src/main/java/com/iluwatar/interpreter/App.java index 5dcd3b81d7b8..d63c78506014 100644 --- a/interpreter/src/main/java/com/iluwatar/interpreter/App.java +++ b/interpreter/src/main/java/com/iluwatar/interpreter/App.java @@ -23,35 +23,30 @@ package com.iluwatar.interpreter; +import java.util.Stack; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.Stack; - /** - * * The Interpreter pattern is a design pattern that specifies how to evaluate sentences in a * language. The basic idea is to have a class for each symbol (terminal or nonterminal) in a * specialized computer language. The syntax tree of a sentence in the language is an instance of * the composite pattern and is used to evaluate (interpret) the sentence for a client. - *

- * In this example we use the Interpreter pattern to break sentences into expressions ( - * {@link Expression}) that can be evaluated and as a whole form the result. - * + * + *

In this example we use the Interpreter pattern to break sentences into expressions ({@link + * Expression}) that can be evaluated and as a whole form the result. */ public class App { private static final Logger LOGGER = LoggerFactory.getLogger(App.class); /** - * * Program entry point. - *

- * Expressions can be evaluated using prefix, infix or postfix notations This sample uses postfix, - * where operator comes after the operands - * + * + *

Expressions can be evaluated using prefix, infix or postfix notations This sample uses + * postfix, where operator comes after the operands. + * * @param args command line args - * */ public static void main(String[] args) { String tokenString = "4 3 2 - 1 + *"; @@ -84,7 +79,7 @@ public static boolean isOperator(String s) { } /** - * Get expression for string + * Get expression for string. */ public static Expression getOperatorInstance(String s, Expression left, Expression right) { switch (s) { diff --git a/interpreter/src/main/java/com/iluwatar/interpreter/Expression.java b/interpreter/src/main/java/com/iluwatar/interpreter/Expression.java index dc9da1177211..dee43b57fb2e 100644 --- a/interpreter/src/main/java/com/iluwatar/interpreter/Expression.java +++ b/interpreter/src/main/java/com/iluwatar/interpreter/Expression.java @@ -24,9 +24,7 @@ package com.iluwatar.interpreter; /** - * - * Expression - * + * Expression. */ public abstract class Expression { diff --git a/interpreter/src/main/java/com/iluwatar/interpreter/MinusExpression.java b/interpreter/src/main/java/com/iluwatar/interpreter/MinusExpression.java index 74ca47bf3610..24ef7914e569 100644 --- a/interpreter/src/main/java/com/iluwatar/interpreter/MinusExpression.java +++ b/interpreter/src/main/java/com/iluwatar/interpreter/MinusExpression.java @@ -24,9 +24,7 @@ package com.iluwatar.interpreter; /** - * - * MinusExpression - * + * MinusExpression. */ public class MinusExpression extends Expression { diff --git a/interpreter/src/main/java/com/iluwatar/interpreter/MultiplyExpression.java b/interpreter/src/main/java/com/iluwatar/interpreter/MultiplyExpression.java index 4ff9d280500d..606937e0bb3a 100644 --- a/interpreter/src/main/java/com/iluwatar/interpreter/MultiplyExpression.java +++ b/interpreter/src/main/java/com/iluwatar/interpreter/MultiplyExpression.java @@ -24,9 +24,7 @@ package com.iluwatar.interpreter; /** - * - * MultiplyExpression - * + * MultiplyExpression. */ public class MultiplyExpression extends Expression { diff --git a/interpreter/src/main/java/com/iluwatar/interpreter/NumberExpression.java b/interpreter/src/main/java/com/iluwatar/interpreter/NumberExpression.java index 035b8a70c406..6b957f6aa104 100644 --- a/interpreter/src/main/java/com/iluwatar/interpreter/NumberExpression.java +++ b/interpreter/src/main/java/com/iluwatar/interpreter/NumberExpression.java @@ -24,9 +24,7 @@ package com.iluwatar.interpreter; /** - * - * NumberExpression - * + * NumberExpression. */ public class NumberExpression extends Expression { diff --git a/interpreter/src/main/java/com/iluwatar/interpreter/PlusExpression.java b/interpreter/src/main/java/com/iluwatar/interpreter/PlusExpression.java index d494a0d68b90..1ce0802599c2 100644 --- a/interpreter/src/main/java/com/iluwatar/interpreter/PlusExpression.java +++ b/interpreter/src/main/java/com/iluwatar/interpreter/PlusExpression.java @@ -24,9 +24,7 @@ package com.iluwatar.interpreter; /** - * - * PlusExpression - * + * PlusExpression. */ public class PlusExpression extends Expression { From c0078a06782f6f2a7970e41cb3b591fb9cb8adfe Mon Sep 17 00:00:00 2001 From: Anurag Agarwal Date: Sun, 10 Nov 2019 01:22:16 +0530 Subject: [PATCH 3/3] Reduces checkstyle errors in iterator --- .../main/java/com/iluwatar/iterator/App.java | 6 ++--- .../java/com/iluwatar/iterator/Iterator.java | 3 ++- .../iluwatar/iterator/bst/BstIterator.java | 8 ++++-- .../com/iluwatar/iterator/bst/TreeNode.java | 4 +-- .../java/com/iluwatar/iterator/list/Item.java | 4 +-- .../com/iluwatar/iterator/list/ItemType.java | 4 +-- .../iluwatar/iterator/list/TreasureChest.java | 26 +++++++++---------- .../list/TreasureChestItemIterator.java | 6 ++--- 8 files changed, 29 insertions(+), 32 deletions(-) diff --git a/iterator/src/main/java/com/iluwatar/iterator/App.java b/iterator/src/main/java/com/iluwatar/iterator/App.java index 13f02f2d72b6..6e72b4ae991d 100644 --- a/iterator/src/main/java/com/iluwatar/iterator/App.java +++ b/iterator/src/main/java/com/iluwatar/iterator/App.java @@ -39,8 +39,8 @@ /** * The Iterator pattern is a design pattern in which an iterator is used to traverse a container and * access the container's elements. The Iterator pattern decouples algorithms from containers. - *

- * In this example the Iterator ({@link Iterator}) adds abstraction layer on top of a collection + * + *

In this example the Iterator ({@link Iterator}) adds abstraction layer on top of a collection * ({@link TreasureChest}). This way the collection can change its internal implementation without * affecting its clients. */ @@ -85,7 +85,7 @@ private static TreeNode buildIntegerBst() { } /** - * Program entry point + * Program entry point. * * @param args command line args */ diff --git a/iterator/src/main/java/com/iluwatar/iterator/Iterator.java b/iterator/src/main/java/com/iluwatar/iterator/Iterator.java index 389d81e93acb..5f399c5b8f7c 100644 --- a/iterator/src/main/java/com/iluwatar/iterator/Iterator.java +++ b/iterator/src/main/java/com/iluwatar/iterator/Iterator.java @@ -24,7 +24,8 @@ package com.iluwatar.iterator; /** - * Iterator interface to be implemented by iterators over various data structures + * Iterator interface to be implemented by iterators over various data structures. + * * @param generically typed for various objects */ public interface Iterator { diff --git a/iterator/src/main/java/com/iluwatar/iterator/bst/BstIterator.java b/iterator/src/main/java/com/iluwatar/iterator/bst/BstIterator.java index 231c750c25c3..87511c7eaad3 100644 --- a/iterator/src/main/java/com/iluwatar/iterator/bst/BstIterator.java +++ b/iterator/src/main/java/com/iluwatar/iterator/bst/BstIterator.java @@ -32,7 +32,7 @@ * expect to retrieve TreeNodes according to the Integer's natural ordering (1, 2, 3...) * * @param This Iterator has been implemented with generic typing to allow for TreeNodes of - * different value types + * different value types */ public class BstIterator> implements Iterator> { @@ -46,7 +46,7 @@ public BstIterator(TreeNode root) { /** * This BstIterator manages to use O(h) extra space, where h is the height of the tree It achieves * this by maintaining a stack of the nodes to handle (pushing all left nodes first), before - * handling self or right node + * handling self or right node. * * @param node TreeNode that acts as root of the subtree we're interested in. */ @@ -58,6 +58,8 @@ private void pushPathToNextSmallest(TreeNode node) { } /** + * Checks if there exists next element. + * * @return true if this iterator has a "next" element */ @Override @@ -66,6 +68,8 @@ public boolean hasNext() { } /** + * Gets the next element. + * * @return TreeNode next. The next element according to our in-order traversal of the given BST * @throws NoSuchElementException if this iterator does not have a next element */ diff --git a/iterator/src/main/java/com/iluwatar/iterator/bst/TreeNode.java b/iterator/src/main/java/com/iluwatar/iterator/bst/TreeNode.java index 87e9fee0b5aa..9d03fdf86743 100644 --- a/iterator/src/main/java/com/iluwatar/iterator/bst/TreeNode.java +++ b/iterator/src/main/java/com/iluwatar/iterator/bst/TreeNode.java @@ -36,7 +36,7 @@ public class TreeNode> { private TreeNode right; /** - * Creates a TreeNode with a given value, and null children + * Creates a TreeNode with a given value, and null children. * * @param val The value of the given node */ @@ -67,7 +67,7 @@ private void setRight(TreeNode right) { } /** - * Inserts new TreeNode based on a given value into the subtree represented by self + * Inserts new TreeNode based on a given value into the subtree represented by self. * * @param valToInsert The value to insert as a new TreeNode */ diff --git a/iterator/src/main/java/com/iluwatar/iterator/list/Item.java b/iterator/src/main/java/com/iluwatar/iterator/list/Item.java index bd934e9f85fc..82e66eb30115 100644 --- a/iterator/src/main/java/com/iluwatar/iterator/list/Item.java +++ b/iterator/src/main/java/com/iluwatar/iterator/list/Item.java @@ -24,9 +24,7 @@ package com.iluwatar.iterator.list; /** - * - * Item - * + * Item. */ public class Item { diff --git a/iterator/src/main/java/com/iluwatar/iterator/list/ItemType.java b/iterator/src/main/java/com/iluwatar/iterator/list/ItemType.java index abb8e0fbb109..fc38046f79ec 100644 --- a/iterator/src/main/java/com/iluwatar/iterator/list/ItemType.java +++ b/iterator/src/main/java/com/iluwatar/iterator/list/ItemType.java @@ -24,9 +24,7 @@ package com.iluwatar.iterator.list; /** - * - * ItemType enumeration - * + * ItemType enumeration. */ public enum ItemType { diff --git a/iterator/src/main/java/com/iluwatar/iterator/list/TreasureChest.java b/iterator/src/main/java/com/iluwatar/iterator/list/TreasureChest.java index 3fb93f5af804..f390c760f356 100644 --- a/iterator/src/main/java/com/iluwatar/iterator/list/TreasureChest.java +++ b/iterator/src/main/java/com/iluwatar/iterator/list/TreasureChest.java @@ -28,29 +28,27 @@ import java.util.List; /** - * * TreasureChest, the collection class. - * */ public class TreasureChest { private List items; /** - * Constructor + * Constructor. */ public TreasureChest() { items = List.of( - new Item(ItemType.POTION, "Potion of courage"), - new Item(ItemType.RING, "Ring of shadows"), - new Item(ItemType.POTION, "Potion of wisdom"), - new Item(ItemType.POTION, "Potion of blood"), - new Item(ItemType.WEAPON, "Sword of silver +1"), - new Item(ItemType.POTION, "Potion of rust"), - new Item(ItemType.POTION, "Potion of healing"), - new Item(ItemType.RING, "Ring of armor"), - new Item(ItemType.WEAPON, "Steel halberd"), - new Item(ItemType.WEAPON, "Dagger of poison")); + new Item(ItemType.POTION, "Potion of courage"), + new Item(ItemType.RING, "Ring of shadows"), + new Item(ItemType.POTION, "Potion of wisdom"), + new Item(ItemType.POTION, "Potion of blood"), + new Item(ItemType.WEAPON, "Sword of silver +1"), + new Item(ItemType.POTION, "Potion of rust"), + new Item(ItemType.POTION, "Potion of healing"), + new Item(ItemType.RING, "Ring of armor"), + new Item(ItemType.WEAPON, "Steel halberd"), + new Item(ItemType.WEAPON, "Dagger of poison")); } public Iterator iterator(ItemType itemType) { @@ -58,7 +56,7 @@ public Iterator iterator(ItemType itemType) { } /** - * Get all items + * Get all items. */ public List getItems() { return new ArrayList<>(items); diff --git a/iterator/src/main/java/com/iluwatar/iterator/list/TreasureChestItemIterator.java b/iterator/src/main/java/com/iluwatar/iterator/list/TreasureChestItemIterator.java index 9ae31e4274c1..43dbc82fa3b0 100644 --- a/iterator/src/main/java/com/iluwatar/iterator/list/TreasureChestItemIterator.java +++ b/iterator/src/main/java/com/iluwatar/iterator/list/TreasureChestItemIterator.java @@ -27,9 +27,7 @@ import java.util.List; /** - * - * TreasureChestItemIterator - * + * TreasureChestItemIterator. */ public class TreasureChestItemIterator implements Iterator { @@ -38,7 +36,7 @@ public class TreasureChestItemIterator implements Iterator { private ItemType type; /** - * Constructor + * Constructor. */ public TreasureChestItemIterator(TreasureChest chest, ItemType type) { this.chest = chest;