Skip to content

Commit b33e10d

Browse files
committed
Groomed code. Mostly formatting stuff.
1 parent 2bfa529 commit b33e10d

File tree

151 files changed

+4857
-4696
lines changed

Some content is hidden

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

151 files changed

+4857
-4696
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,61 @@
1-
package com.gazbert.patterns.behavioural.chainofresponsibility;
2-
3-
/*The MIT License (MIT)
4-
5-
Copyright (c) 2014 Gazbert
6-
7-
Permission is hereby granted, free of charge, to any person obtaining a copy of
8-
this software and associated documentation files (the "Software"), to deal in
9-
the Software without restriction, including without limitation the rights to
10-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11-
the Software, and to permit persons to whom the Software is furnished to do so,
12-
subject to the following conditions:
13-
14-
The above copyright notice and this permission notice shall be included in all
15-
copies or substantial portions of the Software.
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2016 Gareth Jon Lynch
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
* this software and associated documentation files (the "Software"), to deal in
8+
* the Software without restriction, including without limitation the rights to
9+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10+
* the Software, and to permit persons to whom the Software is furnished to do so,
11+
* subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*/
1623

17-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/
24+
package com.gazbert.patterns.behavioural.chainofresponsibility;
2325

2426
/**
25-
*
26-
* Provides the default functionality and 2 operations for subclasses to provide implementations for:
27+
* Provides the default functionality and 2 operations for subclasses to provide implementations for:
2728
* <br>
2829
* (1) deciding if they want to review the document.
2930
* <br>
3031
* (2) method to call to review the document.
3132
* <p>
3233
* Consumers of the pattern call the reviewDocument() method.
33-
*
34-
* @author gazbert
3534
*
35+
* @author gazbert
3636
*/
3737
public abstract class AbstractDocumentReviewHandler implements DocumentReviewHandler {
3838

39-
/** Here for our test assertions to track who's reviewed the document */
39+
/**
40+
* Here for our test assertions to track who's reviewed the document
41+
*/
4042
private static String handledBy = "";
4143

4244
/**
4345
* Holds reference to the next Handler/Receiver.
4446
*/
45-
private DocumentReviewHandler nextHandler;
47+
private DocumentReviewHandler nextHandler;
4648

4749
/**
4850
* Consumers of the pattern call this method to do stuff.
4951
* <p>
5052
* This is the business method.
5153
* <p>
5254
* In this case, JIRA/Bugzilla would call this with the document to review...
53-
*
54-
* @param document
55+
*
56+
* @param document the doc to review
5557
*/
56-
public static void reviewDocumentRequest(final String document)
57-
{
58+
public static void reviewDocumentRequest(String document) {
5859
// Create the handlers/receivers
5960
final DocumentReviewHandler supportReviewHandler = new SupportReviewHandler();
6061
final DocumentReviewHandler salesReviewHandler = new SalesReviewHandler();
@@ -64,16 +65,16 @@ public static void reviewDocumentRequest(final String document)
6465
// Chain em together - totally random order of chaining here ;-)
6566
supportReviewHandler.setNextHandler(salesReviewHandler);
6667
salesReviewHandler.setNextHandler(engineeringReviewHandler);
67-
engineeringReviewHandler.setNextHandler(testingReviewHandler);
68+
engineeringReviewHandler.setNextHandler(testingReviewHandler);
6869
testingReviewHandler.setNextHandler(null); // see NullObjectPattern for better way of 'ending' stuff
6970

7071
// New review request comes in and gets routed to support team first...
7172
supportReviewHandler.processHandler(document);
7273
}
7374

7475
@Override
75-
public void setNextHandler(final DocumentReviewHandler handler) {
76-
this.nextHandler = handler;
76+
public void setNextHandler(DocumentReviewHandler handler) {
77+
this.nextHandler = handler;
7778
}
7879

7980

@@ -87,51 +88,47 @@ public void processHandler(String document) {
8788
boolean wordFound = false;
8889

8990
// check for matching words for this Handler
90-
for (String word : getSelectionCriteria())
91-
{
92-
if (document.indexOf(word) >= 0)
93-
{
91+
for (String word : getSelectionCriteria()) {
92+
if (document.contains(word)) {
9493
wordFound = true;
9594
break;
9695
}
97-
}
96+
}
9897

9998
// Do the handling if we need to...
100-
if (wordFound)
101-
{
99+
if (wordFound) {
102100
handledBy = reviewDocument(document);
103-
}
104-
else
105-
{
101+
} else {
106102
// Check if next Receiver 'wants it'... ;-o
107-
if (null != nextHandler)
108-
{
103+
if (null != nextHandler) {
109104
nextHandler.processHandler(document);
110105
}
111106
}
112107
}
113108

114109
/**
115110
* Only here for unit test code to assert stuff with sake of this demo.
116-
* @return
111+
*
112+
* @return handledBy
117113
*/
118-
public static String getHandledBy()
119-
{
120-
return handledBy;
114+
public static String getHandledBy() {
115+
return handledBy;
121116
}
122117

123118
///////////////////// Subclass contract for the concrete Handlers ////////////////////////
124119

125120
/**
126121
* This is where we ask each Handler for its document review selection criteria.
127-
* @return
122+
*
123+
* @return selection criteria
128124
*/
129125
protected abstract String[] getSelectionCriteria();
130126

131127
/**
132128
* This is where we send the document to interested Handlers.
133-
* @param document
129+
*
130+
* @param document the doc
134131
* @return department that reviewed the document
135-
*/
132+
*/
136133
protected abstract String reviewDocument(String document);
137134
}
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
1-
package com.gazbert.patterns.behavioural.chainofresponsibility;
2-
3-
/*The MIT License (MIT)
4-
5-
Copyright (c) 2014 Gazbert
6-
7-
Permission is hereby granted, free of charge, to any person obtaining a copy of
8-
this software and associated documentation files (the "Software"), to deal in
9-
the Software without restriction, including without limitation the rights to
10-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11-
the Software, and to permit persons to whom the Software is furnished to do so,
12-
subject to the following conditions:
13-
14-
The above copyright notice and this permission notice shall be included in all
15-
copies or substantial portions of the Software.
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2016 Gareth Jon Lynch
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
* this software and associated documentation files (the "Software"), to deal in
8+
* the Software without restriction, including without limitation the rights to
9+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10+
* the Software, and to permit persons to whom the Software is furnished to do so,
11+
* subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*/
1623

17-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/
24+
package com.gazbert.patterns.behavioural.chainofresponsibility;
2325

2426
/**
2527
* Provides operations that each concrete Handler impl must provide.
@@ -32,13 +34,13 @@ public interface DocumentReviewHandler {
3234
/**
3335
* Sets the next handler. The abstract impl usually calls this instead of each concrete impl.
3436
*
35-
* @param handler
37+
* @param handler the doc review handler.
3638
*/
3739
void setNextHandler(DocumentReviewHandler handler);
3840

3941
/**
4042
* Each handler provides its own impl to do something with the message.
41-
* @param document
43+
* @param document the doc.
4244
*/
4345
void processHandler(String document);
4446
}

src/main/java/com/gazbert/patterns/behavioural/chainofresponsibility/EngineeringReviewHandler.java

+23-21
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
1-
package com.gazbert.patterns.behavioural.chainofresponsibility;
2-
3-
/*The MIT License (MIT)
4-
5-
Copyright (c) 2014 Gazbert
6-
7-
Permission is hereby granted, free of charge, to any person obtaining a copy of
8-
this software and associated documentation files (the "Software"), to deal in
9-
the Software without restriction, including without limitation the rights to
10-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11-
the Software, and to permit persons to whom the Software is furnished to do so,
12-
subject to the following conditions:
13-
14-
The above copyright notice and this permission notice shall be included in all
15-
copies or substantial portions of the Software.
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2016 Gareth Jon Lynch
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
* this software and associated documentation files (the "Software"), to deal in
8+
* the Software without restriction, including without limitation the rights to
9+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10+
* the Software, and to permit persons to whom the Software is furnished to do so,
11+
* subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*/
1623

17-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/
24+
package com.gazbert.patterns.behavioural.chainofresponsibility;
2325

2426
/**
2527
* Handler for Engineering team.

src/main/java/com/gazbert/patterns/behavioural/chainofresponsibility/SalesReviewHandler.java

+22-21
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2016 Gareth Jon Lynch
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
* this software and associated documentation files (the "Software"), to deal in
8+
* the Software without restriction, including without limitation the rights to
9+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10+
* the Software, and to permit persons to whom the Software is furnished to do so,
11+
* subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*/
123
package com.gazbert.patterns.behavioural.chainofresponsibility;
224

3-
/*The MIT License (MIT)
4-
5-
Copyright (c) 2014 Gazbert
6-
7-
Permission is hereby granted, free of charge, to any person obtaining a copy of
8-
this software and associated documentation files (the "Software"), to deal in
9-
the Software without restriction, including without limitation the rights to
10-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11-
the Software, and to permit persons to whom the Software is furnished to do so,
12-
subject to the following conditions:
13-
14-
The above copyright notice and this permission notice shall be included in all
15-
copies or substantial portions of the Software.
16-
17-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/
23-
2425
/**
2526
* Handler for Sales team.
2627
*

0 commit comments

Comments
 (0)