Skip to content

Commit efc17fc

Browse files
altaiezioriluwatar
authored andcommitted
Resolves checkstyle errors for business-delegate, bytecode, caching (iluwatar#1059)
* Reduces checkstyle errors in business-delegate * Reduces checkstyle errors in bytecode * Reduces checkstyle errors in caching
1 parent 6d1c0b1 commit efc17fc

21 files changed

Lines changed: 119 additions & 134 deletions

File tree

business-delegate/src/main/java/com/iluwatar/business/delegate/App.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
* tiers. By using the pattern we gain loose coupling between the tiers. The Business Delegate
2929
* encapsulates knowledge about how to locate, connect to, and interact with the business objects
3030
* that make up the application.
31-
*
31+
*
3232
* <p>Some of the services the Business Delegate uses are instantiated directly, and some can be
3333
* retrieved through service lookups. The Business Delegate itself may contain business logic too
3434
* potentially tying together multiple service calls, exception handling, retrying etc.
35-
*
35+
*
3636
* <p>In this example the client ({@link Client}) utilizes a business delegate (
3737
* {@link BusinessDelegate}) to execute a task. The Business Delegate then selects the appropriate
3838
* service and makes the service call.

business-delegate/src/main/java/com/iluwatar/business/delegate/BusinessDelegate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
package com.iluwatar.business.delegate;
2525

2626
/**
27-
* BusinessDelegate separates the presentation and business tiers
27+
* BusinessDelegate separates the presentation and business tiers.
2828
*/
2929
public class BusinessDelegate {
3030

business-delegate/src/main/java/com/iluwatar/business/delegate/BusinessLookup.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public class BusinessLookup {
3333
private JmsService jmsService;
3434

3535
/**
36+
* Gets service instance based on service type.
37+
*
3638
* @param serviceType Type of service instance to be returned.
3739
* @return Service instance.
3840
*/

business-delegate/src/main/java/com/iluwatar/business/delegate/BusinessService.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
package com.iluwatar.business.delegate;
2525

2626
/**
27-
*
28-
* Interface for service implementations
29-
*
27+
* Interface for service implementations.
3028
*/
3129
public interface BusinessService {
3230

business-delegate/src/main/java/com/iluwatar/business/delegate/Client.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
package com.iluwatar.business.delegate;
2525

2626
/**
27-
*
28-
* Client utilizes BusinessDelegate to call the business tier
29-
*
27+
* Client utilizes BusinessDelegate to call the business tier.
3028
*/
3129
public class Client {
3230

business-delegate/src/main/java/com/iluwatar/business/delegate/EjbService.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
import org.slf4j.LoggerFactory;
2828

2929
/**
30-
*
31-
* Service EJB implementation
32-
*
30+
* Service EJB implementation.
3331
*/
3432
public class EjbService implements BusinessService {
3533

business-delegate/src/main/java/com/iluwatar/business/delegate/JmsService.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
import org.slf4j.LoggerFactory;
2828

2929
/**
30-
*
31-
* Service JMS implementation
32-
*
30+
* Service JMS implementation.
3331
*/
3432
public class JmsService implements BusinessService {
3533

business-delegate/src/main/java/com/iluwatar/business/delegate/ServiceType.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
package com.iluwatar.business.delegate;
2525

2626
/**
27-
*
28-
* Enumeration for service types
29-
*
27+
* Enumeration for service types.
3028
*/
3129
public enum ServiceType {
3230

bytecode/src/main/java/com/iluwatar/bytecode/App.java

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,57 +24,59 @@
2424
package com.iluwatar.bytecode;
2525

2626
import com.iluwatar.bytecode.util.InstructionConverterUtil;
27+
import java.util.Stack;
2728
import org.slf4j.Logger;
2829
import org.slf4j.LoggerFactory;
2930

3031
/**
31-
* The intention of Bytecode pattern is to give behavior the flexibility of data by encoding it as instructions
32-
* for a virtual machine.
33-
* An instruction set defines the low-level operations that can be performed. A series of instructions is encoded as
34-
* a sequence of bytes. A virtual machine executes these instructions one at a time,
35-
* using a stack for intermediate values. By combining instructions, complex high-level behavior can be defined.
36-
*
37-
* This pattern should be used when there is a need to define high number of behaviours and implementation engine
38-
* is not a good choice because
39-
* It is too lowe level
40-
* Iterating on it takes too long due to slow compile times or other tooling issues.
41-
* It has too much trust. If you want to ensure the behavior being defined can’t break the game,
42-
* you need to sandbox it from the rest of the codebase.
32+
* The intention of Bytecode pattern is to give behavior the flexibility of data by encoding it as
33+
* instructions for a virtual machine. An instruction set defines the low-level operations that can
34+
* be performed. A series of instructions is encoded as a sequence of bytes. A virtual machine
35+
* executes these instructions one at a time, using a stack for intermediate values. By combining
36+
* instructions, complex high-level behavior can be defined.
4337
*
38+
* <p>This pattern should be used when there is a need to define high number of behaviours and
39+
* implementation engine is not a good choice because It is too lowe level Iterating on it takes too
40+
* long due to slow compile times or other tooling issues. It has too much trust. If you want to
41+
* ensure the behavior being defined can’t break the game, you need to sandbox it from the rest of
42+
* the codebase.
4443
*/
4544
public class App {
4645
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
4746

4847
/**
49-
* Main app method
48+
* Main app method.
49+
*
5050
* @param args command line args
5151
*/
5252
public static void main(String[] args) {
53-
VirtualMachine vm = new VirtualMachine();
5453

5554
Wizard wizard = new Wizard();
5655
wizard.setHealth(45);
5756
wizard.setAgility(7);
5857
wizard.setWisdom(11);
58+
59+
VirtualMachine vm = new VirtualMachine();
5960
vm.getWizards()[0] = wizard;
6061

6162
interpretInstruction("LITERAL 0", vm);
62-
interpretInstruction( "LITERAL 0", vm);
63-
interpretInstruction( "GET_HEALTH", vm);
64-
interpretInstruction( "LITERAL 0", vm);
65-
interpretInstruction( "GET_AGILITY", vm);
66-
interpretInstruction( "LITERAL 0", vm);
67-
interpretInstruction( "GET_WISDOM ", vm);
68-
interpretInstruction( "ADD", vm);
69-
interpretInstruction( "LITERAL 2", vm);
70-
interpretInstruction( "DIVIDE", vm);
71-
interpretInstruction( "ADD", vm);
72-
interpretInstruction( "SET_HEALTH", vm);
63+
interpretInstruction("LITERAL 0", vm);
64+
interpretInstruction("GET_HEALTH", vm);
65+
interpretInstruction("LITERAL 0", vm);
66+
interpretInstruction("GET_AGILITY", vm);
67+
interpretInstruction("LITERAL 0", vm);
68+
interpretInstruction("GET_WISDOM ", vm);
69+
interpretInstruction("ADD", vm);
70+
interpretInstruction("LITERAL 2", vm);
71+
interpretInstruction("DIVIDE", vm);
72+
interpretInstruction("ADD", vm);
73+
interpretInstruction("SET_HEALTH", vm);
7374
}
7475

7576
private static void interpretInstruction(String instruction, VirtualMachine vm) {
7677
InstructionConverterUtil converter = new InstructionConverterUtil();
7778
vm.execute(converter.convertToByteCode(instruction));
78-
LOGGER.info(instruction + String.format("%" + (12 - instruction.length()) + "s", "" ) + vm.getStack());
79+
Stack<Integer> stack = vm.getStack();
80+
LOGGER.info(instruction + String.format("%" + (12 - instruction.length()) + "s", "") + stack);
7981
}
8082
}

bytecode/src/main/java/com/iluwatar/bytecode/Instruction.java

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

2626
/**
27-
* Representation of instructions understandable by virtual machine
27+
* Representation of instructions understandable by virtual machine.
2828
*/
2929
public enum Instruction {
3030

@@ -51,7 +51,8 @@ public int getIntValue() {
5151
}
5252

5353
/**
54-
* Converts integer value to Instruction
54+
* Converts integer value to Instruction.
55+
*
5556
* @param value value of instruction
5657
* @return representation of the instruction
5758
*/

0 commit comments

Comments
 (0)