Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1fa8a60
Sharding Pattern (#1056)
Azureyjt Nov 8, 2019
6d1c0b1
Resolves checkstyle errors for ambassador, async-method-invocation, b…
anuragagarwal561994 Nov 9, 2019
efc17fc
Resolves checkstyle errors for business-delegate, bytecode, caching (…
anuragagarwal561994 Nov 9, 2019
31f27a7
Resolves checkstyle errors for callback, chain, circuit-breaker (#1060)
anuragagarwal561994 Nov 9, 2019
2f49648
Resolves checkstyle errors for collection-pipeline, command, commande…
anuragagarwal561994 Nov 9, 2019
4f9ee01
Resolves checkstyle errors for converter, cqrs (#1063)
anuragagarwal561994 Nov 10, 2019
dda0953
Resolves checkstyle errors for guarded-suspension, half-sync-half-asy…
anuragagarwal561994 Nov 10, 2019
7f06f3b
Resolves checkstyle errors for intercepting-filter, interpreter, iter…
anuragagarwal561994 Nov 10, 2019
eae09fc
Resolves checkstyle errors for api-gateway, lazy-loading, leader-elec…
anuragagarwal561994 Nov 10, 2019
01e489c
Resolves checkstyle errors for dao data-bus data-locality data-mapper…
anuragagarwal561994 Nov 10, 2019
f2c91eb
Resolves checkstyle errors for delegation dependency-injection dirty-…
anuragagarwal561994 Nov 10, 2019
7c888e8
Resolves checkstyle errors for eip-* (#1069)
anuragagarwal561994 Nov 10, 2019
5ae2ce6
Resolves checkstyle errors for event-* (#1070)
anuragagarwal561994 Nov 10, 2019
4dae1fa
Resolves checkstyle errors for execute-around extension-objects (#1071)
anuragagarwal561994 Nov 10, 2019
9c8ad44
Resolves checkstyle errors for patterns starting with letter r (#1072)
anuragagarwal561994 Nov 10, 2019
b92eb52
Resolves checkstyle errors for template-method thread-pool throttling…
anuragagarwal561994 Nov 10, 2019
f0f0143
Resolves checkstyle errors for trampoline twin typeobjectpattern unit…
anuragagarwal561994 Nov 10, 2019
c441831
Java 11 migration: ambassador async-method-invocation balking bridge …
anuragagarwal561994 Nov 11, 2019
329479d
#984 update Ambassador readme
iluwatar Nov 11, 2019
0272d71
#984 update Bridge readme
iluwatar Nov 11, 2019
2628cc0
#984 update Builder readme
iluwatar Nov 11, 2019
c954a43
Resolves checkstyle errors for facade factory-kit spatial-partition s…
anuragagarwal561994 Nov 11, 2019
37599eb
Resolves checkstyle errors for feature-toggle fluentinterface flux fl…
anuragagarwal561994 Nov 11, 2019
3907951
Resolves checkstyle issues for semaphore servant serverless service-l…
anuragagarwal561994 Nov 11, 2019
1e76d91
Resolves checkstyle errors for abstract-document abstract-factory acy…
anuragagarwal561994 Nov 11, 2019
6ef840f
Resolves checkstyle errors for naked-objects null-object object-mothe…
anuragagarwal561994 Nov 12, 2019
33ea733
Java 11 migration: patterns (remaining b-c) (#1081)
anuragagarwal561994 Nov 12, 2019
3c57bf7
#984 #987 update readmes
iluwatar Nov 12, 2019
f04fc3c
Java 11 migration: patterns starting with a (#1084)
anuragagarwal561994 Nov 13, 2019
160b737
Add another real world example for Builder
iluwatar Nov 13, 2019
50467c9
Java 11 migration: patterns (t-v) (#1085)
anuragagarwal561994 Nov 14, 2019
cc571f4
Saga pattern (#1062)
besok Nov 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Resolves checkstyle errors for intercepting-filter, interpreter, iter…
…ator (iluwatar#1065)

* Reduces checkstyle errors in intercepting-filter

* Reduces checkstyle errors in interpreter

* Reduces checkstyle errors in iterator
  • Loading branch information
anuragagarwal561994 authored and iluwatar committed Nov 10, 2019
commit 7f06f3b78c9e6cb900606d2fb5bb3af2cac93978
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,33 @@
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
* violate any constraints? - What encoding does the client use to send the data? - Do we support
* 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
* <p>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

Expand All @@ -57,7 +57,7 @@ public class Client extends JFrame { // NOSONAR
private JButton processButton;

/**
* Constructor
* Constructor.
*/
public Client() {
super("Client System");
Expand Down Expand Up @@ -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));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

/**
* Filter Chain carries multiple filters and help to execute them in defined order on target.
*
*
* @author joshzambales
*/
public class FilterChain {
Expand All @@ -35,7 +35,7 @@ public class FilterChain {


/**
* Adds filter
* Adds filter.
*/
public void addFilter(Filter filter) {
if (chain == null) {
Expand All @@ -46,7 +46,7 @@ public void addFilter(Filter filter) {
}

/**
* Execute filter chain
* Execute filter chain.
*/
public String execute(Order order) {
if (chain != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@

/**
* Filter Manager manages the filters and {@link FilterChain}.
*
* @author joshzambales
*
* @author joshzambales
*/
public class FilterManager {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

/**
* Order class carries the order data.
*
*/
public class Order {

Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@

/**
* Concrete implementation of filter. This checks for the order field.
*
* @author joshzambales
*
* @author joshzambales
*/
public class OrderFilter extends AbstractFilter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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

Expand All @@ -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");
Expand All @@ -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 {
Expand Down
23 changes: 9 additions & 14 deletions interpreter/src/main/java/com/iluwatar/interpreter/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p>
* 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.
*
*
* <p>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.
* <p>
* Expressions can be evaluated using prefix, infix or postfix notations This sample uses postfix,
* where operator comes after the operands
*
*
* <p>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 + *";
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
package com.iluwatar.interpreter;

/**
*
* Expression
*
* Expression.
*/
public abstract class Expression {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
package com.iluwatar.interpreter;

/**
*
* MinusExpression
*
* MinusExpression.
*/
public class MinusExpression extends Expression {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
package com.iluwatar.interpreter;

/**
*
* MultiplyExpression
*
* MultiplyExpression.
*/
public class MultiplyExpression extends Expression {

Expand Down
Loading