|
|
@@ -27,7 +27,6 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
|
|
/**
|
|
|
* The class {@code Connector} represents a created connector
|
|
|
* which allows to be scheduled by defined period.
|
|
|
- *
|
|
|
* The idea is to wrap functionality of a connector. The flow is
|
|
|
* defined as 'fetcher' -> 'converter' -> 'pusher'.
|
|
|
*
|
|
|
@@ -52,18 +51,18 @@ public final class Connector {
|
|
|
private final ExecutableFetcher<? super AbstractModel> fetcherExecutor;
|
|
|
|
|
|
/** Instance of a pusher that receives data. */
|
|
|
- private final ConnectorPusher<? super AbstractModel> pusher; // TODO refactor to a ExecutableFetcher
|
|
|
+ private final ConnectorPusher<? super AbstractModel> pusher;
|
|
|
|
|
|
/** Converter between fetch and push. */
|
|
|
private final Converter<? super AbstractModel, ? super AbstractModel> converter;
|
|
|
|
|
|
/** Period for scheduler. */
|
|
|
- private final Optional<Integer> period;
|
|
|
+ private final Integer period;
|
|
|
|
|
|
/** Initialization delay for scheduler. */
|
|
|
- private final Optional<Integer> initDelay;
|
|
|
+ private final Integer initDelay;
|
|
|
|
|
|
- private final Optional<LocalTime> startAt;
|
|
|
+ private final LocalTime startAt;
|
|
|
|
|
|
/**
|
|
|
* Constructor allows to set all attributes.
|
|
|
@@ -86,9 +85,9 @@ public final class Connector {
|
|
|
this.fetcherExecutor = fetcherExecutor;
|
|
|
this.pusher = pusher;
|
|
|
this.converter = converter;
|
|
|
- this.period = ofNullable(period != null ? period * 1_000 : null); // to millis
|
|
|
- this.initDelay = ofNullable(initDelay != null ? initDelay * 1_000 : null); // to millis
|
|
|
- this.startAt = ofNullable(startAt);
|
|
|
+ this.period = period != null ? period * 1_000 : null; // to millis
|
|
|
+ this.initDelay = initDelay != null ? initDelay * 1_000 : null; // to millis
|
|
|
+ this.startAt = startAt;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -104,7 +103,7 @@ public final class Connector {
|
|
|
* @return period for scheduler.
|
|
|
*/
|
|
|
public Optional<Integer> getPeriod() {
|
|
|
- return period;
|
|
|
+ return ofNullable(period);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -112,7 +111,7 @@ public final class Connector {
|
|
|
* @return delay for scheduler.
|
|
|
*/
|
|
|
public Optional<Integer> getInitDelay() {
|
|
|
- return initDelay;
|
|
|
+ return ofNullable(initDelay);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -120,7 +119,7 @@ public final class Connector {
|
|
|
* @return time to execute the connector
|
|
|
*/
|
|
|
public Optional<LocalTime> getStartAt() {
|
|
|
- return startAt;
|
|
|
+ return ofNullable(startAt);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -132,7 +131,7 @@ public final class Connector {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Schedules connector according by settings. Input parameters are scheduled service
|
|
|
+ * Schedules connector according to settings. Input parameters are scheduled service
|
|
|
* {@link ScheduledExecutorService} and {@link CountDownLatch} uses as a thread barrier.
|
|
|
* @param scheduledService - scheduled service
|
|
|
* @param latch - thread counter
|