Resolves checkstyle errors for intercepting-filter, interpreter, iterator (#1065)

* Reduces checkstyle errors in intercepting-filter

* Reduces checkstyle errors in interpreter

* Reduces checkstyle errors in iterator
This commit is contained in:
Anurag Agarwal
2019-11-10 22:35:05 +05:30
committed by Ilkka Seppälä
parent dda09535e6
commit 7f06f3b78c
27 changed files with 99 additions and 122 deletions

View File

@ -25,13 +25,13 @@ package com.iluwatar.intercepting.filter;
/**
* 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;

View File

@ -26,9 +26,8 @@ package com.iluwatar.intercepting.filter;
/**
* 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 {

View File

@ -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 @@ package com.iluwatar.intercepting.filter;
* 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.
* <p>
* 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.
* <p>
* The key to solving this problem in a flexible and unobtrusive manner is to have a simple
*
* <p>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.
*
* <p>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.
* <p>
* 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}
* <p>
*
* @author joshzambales
*
* <p>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) {

View File

@ -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.JTextArea;
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}.
*
* <p>This is where {@link Filter}s come to play as the client pre-processes the request before
* being displayed in the {@link Target}.
*
* 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 @@ public class Client extends JFrame { // NOSONAR
});
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));
});

View File

@ -26,10 +26,9 @@ package com.iluwatar.intercepting.filter;
/**
* 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 {

View File

@ -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 {

View File

@ -26,9 +26,8 @@ package com.iluwatar.intercepting.filter;
/**
* 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 {

View File

@ -26,7 +26,7 @@ package com.iluwatar.intercepting.filter;
/**
* 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 class FilterChain {
}
/**
* Execute filter chain
* Execute filter chain.
*/
public String execute(Order order) {
if (chain != null) {

View File

@ -25,9 +25,8 @@ package com.iluwatar.intercepting.filter;
/**
* Filter Manager manages the filters and {@link FilterChain}.
*
* @author joshzambales
*
* @author joshzambales
*/
public class FilterManager {

View File

@ -26,9 +26,8 @@ package com.iluwatar.intercepting.filter;
/**
* 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 {

View File

@ -25,7 +25,6 @@ package com.iluwatar.intercepting.filter;
/**
* 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;

View File

@ -25,9 +25,8 @@ package com.iluwatar.intercepting.filter;
/**
* Concrete implementation of filter. This checks for the order field.
*
* @author joshzambales
*
* @author joshzambales
*/
public class OrderFilter extends AbstractFilter {

View File

@ -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.JTable;
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 @@ public class Target extends JFrame { //NOSONAR
}
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 {