mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-15 06:58:41 +00:00
* #2449 bump maven-checkstyle-plugin from 3.1.0 to 3.2.0 + resolve checkstyle issues * remove FileSelectorJFrame.java to resolve checkstyle issue * remove FileSelectorJFrame.java to resolve checkstyle issue * remove FileSelectorJFrame.java to resolve checkstyle issue * add refactored file with correct filename to resolve checkstyle issue * add the test data * change filenames from JFrame to Jframe for checkstyle * fix code smell from sonar report * add new testcases to improve the test coverage * remove code smell
This commit is contained in:
@@ -29,7 +29,7 @@ import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* EventManager handles and maintains a pool of event threads. {@link Event} threads are created
|
||||
* EventManager handles and maintains a pool of event threads. {@link AsyncEvent} threads are created
|
||||
* upon user request. Thre are two types of events; Asynchronous and Synchronous. There can be
|
||||
* multiple Asynchronous events running at once but only one Synchronous event running at a time.
|
||||
* Currently supported event operations are: start, stop, and getStatus. Once an event is complete,
|
||||
@@ -45,7 +45,7 @@ public class EventManager implements ThreadCompleteListener {
|
||||
public static final int MAX_EVENT_TIME = 1800; // in seconds / 30 minutes.
|
||||
private int currentlyRunningSyncEvent = -1;
|
||||
private final SecureRandom rand;
|
||||
private final Map<Integer, Event> eventPool;
|
||||
private final Map<Integer, AsyncEvent> eventPool;
|
||||
|
||||
private static final String DOES_NOT_EXIST = " does not exist.";
|
||||
|
||||
@@ -108,7 +108,7 @@ public class EventManager implements ThreadCompleteListener {
|
||||
|
||||
var newEventId = generateId();
|
||||
|
||||
var newEvent = new Event(newEventId, eventTime, isSynchronous);
|
||||
var newEvent = new AsyncEvent(newEventId, eventTime, isSynchronous);
|
||||
newEvent.addListener(this);
|
||||
eventPool.put(newEventId, newEvent);
|
||||
|
||||
@@ -167,7 +167,7 @@ public class EventManager implements ThreadCompleteListener {
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void statusOfAllEvents() {
|
||||
eventPool.entrySet().forEach(entry -> ((Event) ((Map.Entry) entry).getValue()).status());
|
||||
eventPool.entrySet().forEach(entry -> ((AsyncEvent) ((Map.Entry) entry).getValue()).status());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,7 +175,7 @@ public class EventManager implements ThreadCompleteListener {
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void shutdown() {
|
||||
eventPool.entrySet().forEach(entry -> ((Event) ((Map.Entry) entry).getValue()).stop());
|
||||
eventPool.entrySet().forEach(entry -> ((AsyncEvent) ((Map.Entry) entry).getValue()).stop());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,7 +195,7 @@ public class EventManager implements ThreadCompleteListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback from an {@link Event} (once it is complete). The Event is then removed from the pool.
|
||||
* Callback from an {@link AsyncEvent} (once it is complete). The Event is then removed from the pool.
|
||||
*/
|
||||
@Override
|
||||
public void completedEventHandler(int eventId) {
|
||||
@@ -209,7 +209,7 @@ public class EventManager implements ThreadCompleteListener {
|
||||
/**
|
||||
* Getter method for event pool.
|
||||
*/
|
||||
public Map<Integer, Event> getEventPool() {
|
||||
public Map<Integer, AsyncEvent> getEventPool() {
|
||||
return eventPool;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user