Skip to content

Commit 1fdc650

Browse files
anuragagarwal561994iluwatar
authored andcommitted
Resolves checkstyle errors for remaining m (#1090)
* Reduces checkstyle errors in marker * Reduces checkstyle errors in master-worker-pattern * Reduces checkstyle errors in mediator * Reduces checkstyle errors in memento * Reduces checkstyle errors in model-view-controller * Reduces checkstyle errors in model-view-presenter * Reduces checkstyle errors in module * Reduces checkstyle errors in monad * Reduces checkstyle errors in monostate * Reduces checkstyle errors in multiton * Reduces checkstyle errors in mute-idiom * Reduces checkstyle errors in mutex
1 parent 3ccc9ba commit 1fdc650

File tree

66 files changed

+374
-423
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+374
-423
lines changed

marker/src/main/java/App.java

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,23 @@
2525
import org.slf4j.LoggerFactory;
2626

2727
/**
28-
* Created by Alexis on 28-Apr-17.
29-
* With Marker interface idea is to make empty interface and extend it.
30-
* Basically it is just to identify the special objects from normal objects.
31-
* Like in case of serialization , objects that need to be serialized must implement serializable interface
32-
* (it is empty interface) and down the line writeObject() method must be checking
33-
* if it is a instance of serializable or not.
34-
* <p>
35-
* Marker interface vs annotation
36-
* Marker interfaces and marker annotations both have their uses,
37-
* neither of them is obsolete or always better then the other one.
38-
* If you want to define a type that does not have any new methods associated with it,
39-
* a marker interface is the way to go.
40-
* If you want to mark program elements other than classes and interfaces,
41-
* to allow for the possibility of adding more information to the marker in the future,
42-
* or to fit the marker into a framework that already makes heavy use of annotation types,
43-
* then a marker annotation is the correct choice
28+
* Created by Alexis on 28-Apr-17. With Marker interface idea is to make empty interface and extend
29+
* it. Basically it is just to identify the special objects from normal objects. Like in case of
30+
* serialization , objects that need to be serialized must implement serializable interface (it is
31+
* empty interface) and down the line writeObject() method must be checking if it is a instance of
32+
* serializable or not.
33+
*
34+
* <p>Marker interface vs annotation Marker interfaces and marker annotations both have their uses,
35+
* neither of them is obsolete or always better then the other one. If you want to define a type
36+
* that does not have any new methods associated with it, a marker interface is the way to go. If
37+
* you want to mark program elements other than classes and interfaces, to allow for the possibility
38+
* of adding more information to the marker in the future, or to fit the marker into a framework
39+
* that already makes heavy use of annotation types, then a marker annotation is the correct choice
4440
*/
4541
public class App {
4642

4743
/**
48-
* Program entry point
44+
* Program entry point.
4945
*
5046
* @param args command line args
5147
*/

marker/src/main/java/Guard.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import org.slf4j.LoggerFactory;
2626

2727
/**
28-
* Class defining Guard
28+
* Class defining Guard.
2929
*/
3030
public class Guard implements Permission {
3131

marker/src/main/java/Permission.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
*/
2323

2424
/**
25-
* Interface without any methods
26-
* Marker interface is based on that assumption
25+
* Interface without any methods Marker interface is based on that assumption.
2726
*/
2827
public interface Permission {
2928
}

marker/src/main/java/Thief.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import org.slf4j.LoggerFactory;
2626

2727
/**
28-
* Class defining Thief
28+
* Class defining Thief.
2929
*/
3030
public class Thief {
3131

master-worker-pattern/src/main/java/com/iluwatar/masterworker/App.java

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,40 +28,47 @@
2828
import org.slf4j.LoggerFactory;
2929

3030
/**
31-
* <p>The <b><em>Master-Worker</em></b> pattern is used when the problem at hand can be solved by dividing into
32-
* multiple parts which need to go through the same computation and may need to be aggregated to get final result.
33-
* Parallel processing is performed using a system consisting of a master and some number of workers, where a
34-
* master divides the work among the workers, gets the result back from them and assimilates all the results to
35-
* give final result. The only communication is between the master and the worker - none of the workers communicate
36-
* among one another and the user only communicates with the master to get required job done.</p>
37-
* <p>In our example, we have generic abstract classes {@link MasterWorker}, {@link Master} and {@link Worker} which
38-
* have to be extended by the classes which will perform the specific job at hand (in this case finding transpose of
39-
* matrix, done by {@link ArrayTransposeMasterWorker}, {@link ArrayTransposeMaster} and {@link ArrayTransposeWorker}).
40-
* The Master class divides the work into parts to be given to the workers, collects the results from the workers and
41-
* aggregates it when all workers have responded before returning the solution. The Worker class extends the Thread
42-
* class to enable parallel processing, and does the work once the data has been received from the Master. The
43-
* MasterWorker contains a reference to the Master class, gets the input from the App and passes it on to the Master.
44-
* These 3 classes define the system which computes the result. We also have 2 abstract classes {@link Input} and
45-
* {@link Result}, which contain the input data and result data respectively. The Input class also has an abstract
46-
* method divideData which defines how the data is to be divided into segments. These classes are extended by
47-
* {@link ArrayInput} and {@link ArrayResult}.</p>
31+
* <p>The <b><em>Master-Worker</em></b> pattern is used when the problem at hand can be solved by
32+
* dividing into
33+
* multiple parts which need to go through the same computation and may need to be aggregated to get
34+
* final result. Parallel processing is performed using a system consisting of a master and some
35+
* number of workers, where a master divides the work among the workers, gets the result back from
36+
* them and assimilates all the results to give final result. The only communication is between the
37+
* master and the worker - none of the workers communicate among one another and the user only
38+
* communicates with the master to get required job done.</p>
39+
* <p>In our example, we have generic abstract classes {@link MasterWorker}, {@link Master} and
40+
* {@link Worker} which
41+
* have to be extended by the classes which will perform the specific job at hand (in this case
42+
* finding transpose of matrix, done by {@link ArrayTransposeMasterWorker}, {@link
43+
* ArrayTransposeMaster} and {@link ArrayTransposeWorker}). The Master class divides the work into
44+
* parts to be given to the workers, collects the results from the workers and aggregates it when
45+
* all workers have responded before returning the solution. The Worker class extends the Thread
46+
* class to enable parallel processing, and does the work once the data has been received from the
47+
* Master. The MasterWorker contains a reference to the Master class, gets the input from the App
48+
* and passes it on to the Master. These 3 classes define the system which computes the result. We
49+
* also have 2 abstract classes {@link Input} and {@link Result}, which contain the input data and
50+
* result data respectively. The Input class also has an abstract method divideData which defines
51+
* how the data is to be divided into segments. These classes are extended by {@link ArrayInput} and
52+
* {@link ArrayResult}.</p>
4853
*/
4954

5055
public class App {
5156

5257
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
58+
5359
/**
5460
* Program entry point.
61+
*
5562
* @param args command line args
5663
*/
5764

5865
public static void main(String[] args) {
5966
ArrayTransposeMasterWorker mw = new ArrayTransposeMasterWorker();
6067
int rows = 10;
6168
int columns = 20;
62-
int[][] inputMatrix = ArrayUtilityMethods.createRandomIntMatrix(rows,columns);
69+
int[][] inputMatrix = ArrayUtilityMethods.createRandomIntMatrix(rows, columns);
6370
ArrayInput input = new ArrayInput(inputMatrix);
64-
ArrayResult result = (ArrayResult) mw.getResult(input);
71+
ArrayResult result = (ArrayResult) mw.getResult(input);
6572
if (result != null) {
6673
ArrayUtilityMethods.printMatrix(inputMatrix);
6774
ArrayUtilityMethods.printMatrix(result.data);

master-worker-pattern/src/main/java/com/iluwatar/masterworker/ArrayInput.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,15 @@
2727
import java.util.Arrays;
2828

2929
/**
30-
*Class ArrayInput extends abstract class {@link Input} and contains data
31-
*of type int[][].
30+
* Class ArrayInput extends abstract class {@link Input} and contains data of type int[][].
3231
*/
3332

3433
public class ArrayInput extends Input<int[][]> {
3534

3635
public ArrayInput(int[][] data) {
3736
super(data);
3837
}
39-
38+
4039
static int[] makeDivisions(int[][] data, int num) {
4140
int initialDivision = data.length / num; //equally dividing
4241
int[] divisions = new int[num];
@@ -81,6 +80,6 @@ public ArrayList<Input> divideData(int num) {
8180
}
8281
}
8382
return result;
84-
}
85-
}
83+
}
84+
}
8685
}

master-worker-pattern/src/main/java/com/iluwatar/masterworker/ArrayResult.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
package com.iluwatar.masterworker;
2525

2626
/**
27-
*Class ArrayResult extends abstract class {@link Result} and contains data
28-
*of type int[][].
27+
* Class ArrayResult extends abstract class {@link Result} and contains data of type int[][].
2928
*/
3029

3130
public class ArrayResult extends Result<int[][]> {

master-worker-pattern/src/main/java/com/iluwatar/masterworker/ArrayUtilityMethods.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,23 @@
2323

2424
package com.iluwatar.masterworker;
2525

26+
import java.util.Random;
2627
import org.slf4j.Logger;
2728
import org.slf4j.LoggerFactory;
2829

29-
import java.util.Random;
30-
3130
/**
32-
*Class ArrayUtilityMethods has some utility methods for matrices and arrays.
31+
* Class ArrayUtilityMethods has some utility methods for matrices and arrays.
3332
*/
3433

3534
public class ArrayUtilityMethods {
3635

3736
private static final Logger LOGGER = LoggerFactory.getLogger(ArrayUtilityMethods.class);
38-
37+
3938
private static final Random RANDOM = new Random();
39+
4040
/**
41-
* Method arraysSame compares 2 arrays @param a1 and @param a2
42-
* and @return whether their values are equal (boolean).
41+
* Method arraysSame compares 2 arrays @param a1 and @param a2 and @return whether their values
42+
* are equal (boolean).
4343
*/
4444

4545
public static boolean arraysSame(int[] a1, int[] a2) {
@@ -61,10 +61,10 @@ public static boolean arraysSame(int[] a1, int[] a2) {
6161
}
6262

6363
/**
64-
* Method matricesSame compares 2 matrices @param m1 and @param m2
65-
* and @return whether their values are equal (boolean).
64+
* Method matricesSame compares 2 matrices @param m1 and @param m2 and @return whether their
65+
* values are equal (boolean).
6666
*/
67-
67+
6868
public static boolean matricesSame(int[][] m1, int[][] m2) {
6969
if (m1.length != m2.length) {
7070
return false;
@@ -81,12 +81,12 @@ public static boolean matricesSame(int[][] m1, int[][] m2) {
8181
return answer;
8282
}
8383
}
84-
84+
8585
/**
86-
* Method createRandomIntMatrix creates a random matrix of size @param rows
87-
* and @param columns @return it (int[][]).
86+
* Method createRandomIntMatrix creates a random matrix of size @param rows and @param columns.
87+
*
88+
* @return it (int[][]).
8889
*/
89-
9090
public static int[][] createRandomIntMatrix(int rows, int columns) {
9191
int[][] matrix = new int[rows][columns];
9292
for (int i = 0; i < rows; i++) {
@@ -97,11 +97,11 @@ public static int[][] createRandomIntMatrix(int rows, int columns) {
9797
}
9898
return matrix;
9999
}
100-
100+
101101
/**
102102
* Method printMatrix prints input matrix @param matrix.
103103
*/
104-
104+
105105
public static void printMatrix(int[][] matrix) {
106106
//prints out int[][]
107107
for (int i = 0; i < matrix.length; i++) {
@@ -111,5 +111,5 @@ public static void printMatrix(int[][] matrix) {
111111
LOGGER.info("");
112112
}
113113
}
114-
114+
115115
}

master-worker-pattern/src/main/java/com/iluwatar/masterworker/Input.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,19 @@
2626
import java.util.ArrayList;
2727

2828
/**
29-
*The abstract Input class, having 1 public field which contains input data,
30-
*and abstract method divideData.
29+
* The abstract Input class, having 1 public field which contains input data, and abstract method
30+
* divideData.
31+
*
3132
* @param <T> T will be type of data.
3233
*/
3334

3435
public abstract class Input<T> {
35-
36+
3637
public final T data;
37-
38+
3839
public Input(T data) {
3940
this.data = data;
4041
}
41-
42+
4243
public abstract ArrayList<Input> divideData(int num);
4344
}

master-worker-pattern/src/main/java/com/iluwatar/masterworker/Result.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
package com.iluwatar.masterworker;
2525

2626
/**
27-
*The abstract Result class, which contains 1 public field containing result
28-
*data.
27+
* The abstract Result class, which contains 1 public field containing result data.
28+
*
2929
* @param <T> T will be type of data.
3030
*/
3131

3232
public abstract class Result<T> {
33-
33+
3434
public final T data;
3535

3636
public Result(T data) {

0 commit comments

Comments
 (0)