From b1c5d05bbc608880d6b7a8fd414aafc4b1390fd0 Mon Sep 17 00:00:00 2001
From: Robert von Burg
Date: Mon, 24 Jul 2023 13:39:28 +0200
Subject: [PATCH] [Minor] Code formatting
---
.../java/li/strolch/plc/core/PlcService.java | 242 ++++++------------
1 file changed, 82 insertions(+), 160 deletions(-)
diff --git a/plc-core/src/main/java/li/strolch/plc/core/PlcService.java b/plc-core/src/main/java/li/strolch/plc/core/PlcService.java
index f25faa9..65b6457 100644
--- a/plc-core/src/main/java/li/strolch/plc/core/PlcService.java
+++ b/plc-core/src/main/java/li/strolch/plc/core/PlcService.java
@@ -78,8 +78,7 @@ public abstract class PlcService implements PlcListener {
* Called to initialize this service, here one would read the model state of a given address using
* {@link #getAddressState(StrolchTransaction, String, String)}
*
- * @param tx
- * the transaction giving access to the model
+ * @param tx the transaction giving access to the model
*/
public void start(StrolchTransaction tx) {
this.state = PlcServiceState.Started;
@@ -110,10 +109,8 @@ public abstract class PlcService implements PlcListener {
/**
* Register this service with the given resource and action
*
- * @param resource
- * the resource ID
- * @param action
- * the action
+ * @param resource the resource ID
+ * @param action the action
*/
public void register(String resource, String action) {
this.plcHandler.register(resource, action, this);
@@ -123,10 +120,8 @@ public abstract class PlcService implements PlcListener {
/**
* Unregister this service with the given resource and action
*
- * @param resource
- * the resource ID
- * @param action
- * the action
+ * @param resource the resource ID
+ * @param action the action
*/
public void unregister(String resource, String action) {
this.plcHandler.unregister(resource, action, this);
@@ -142,12 +137,9 @@ public abstract class PlcService implements PlcListener {
/**
* Returns the {@link Resource} of type #TYPE_PLC_ADDRESS for the given resource and action
*
- * @param tx
- * the current TX
- * @param resource
- * the resource
- * @param action
- * the action
+ * @param tx the current TX
+ * @param resource the resource
+ * @param action the action
*
* @return the {@link Resource}
*/
@@ -160,14 +152,10 @@ public abstract class PlcService implements PlcListener {
* Returns the value of a plc address by calling {@link #getPlcAddress(StrolchTransaction, String, String)} for the
* given resource and action
*
- * @param tx
- * the current TX
- * @param resource
- * the resource
- * @param action
- * the action
- * @param
- * the type of value to return
+ * @param tx the current TX
+ * @param resource the resource
+ * @param action the action
+ * @param the type of value to return
*
* @return the value of the given address
*/
@@ -179,12 +167,9 @@ public abstract class PlcService implements PlcListener {
/**
* Enables an operations log message to be seen by a user
*
- * @param addressKey
- * the address for which the message is enabled
- * @param bundle
- * the resource bundle containing the message
- * @param severity
- * the severity of the message
+ * @param addressKey the address for which the message is enabled
+ * @param bundle the resource bundle containing the message
+ * @param severity the severity of the message
*/
protected void enableMsg(PlcAddressKey addressKey, ResourceBundle bundle, LogSeverity severity) {
sendMsg(logMessageFor(addressKey, bundle, severity, LogMessageState.Active));
@@ -193,8 +178,7 @@ public abstract class PlcService implements PlcListener {
/**
* Disables an operations log message which was previously enabled
*
- * @param addressKey
- * the address for which the message was enabled
+ * @param addressKey the address for which the message was enabled
*/
protected void disableMsg(PlcAddressKey addressKey) {
disableMsg(Locator.valueOf("Plc", this.plcHandler.getPlcId(), addressKey.resource, addressKey.action));
@@ -203,12 +187,9 @@ public abstract class PlcService implements PlcListener {
/**
* Enables an operations log message to be seen by a user
*
- * @param i18nKey
- * the key of the message in the resource bundle
- * @param bundle
- * the resource bundle containing the message
- * @param severity
- * the severity of the message
+ * @param i18nKey the key of the message in the resource bundle
+ * @param bundle the resource bundle containing the message
+ * @param severity the severity of the message
*/
protected void enableMsg(String i18nKey, ResourceBundle bundle, LogSeverity severity) {
sendMsg(logMessageFor(i18nKey, bundle, severity, LogMessageState.Active));
@@ -217,10 +198,8 @@ public abstract class PlcService implements PlcListener {
/**
* Disables an operations log message which was previously enabled
*
- * @param i18nKey
- * the key of the message in the resource bundle for which the message was enabled
- * @param bundle
- * the resource bundle containing the message
+ * @param i18nKey the key of the message in the resource bundle for which the message was enabled
+ * @param bundle the resource bundle containing the message
*/
protected void disableMsg(String i18nKey, ResourceBundle bundle) {
disableMsg(Locator.valueOf("Plc", this.plcHandler.getPlcId(), bundle.getBaseBundleName(), i18nKey));
@@ -229,12 +208,9 @@ public abstract class PlcService implements PlcListener {
/**
* Sends a message created for the given properties to a remote listener
*
- * @param i18nKey
- * the key of the message
- * @param bundle
- * the bundle containing the key
- * @param severity
- * the severity of the message
+ * @param i18nKey the key of the message
+ * @param bundle the bundle containing the key
+ * @param severity the severity of the message
*/
protected void sendMsg(String i18nKey, ResourceBundle bundle, LogSeverity severity) {
sendMsg(logMessageFor(i18nKey, bundle, severity));
@@ -243,12 +219,9 @@ public abstract class PlcService implements PlcListener {
/**
* Creates a {@link LogMessage} for the given fields
*
- * @param addressKey
- * the address for the key
- * @param bundle
- * the bundle containing the message
- * @param severity
- * the severity of the message
+ * @param addressKey the address for the key
+ * @param bundle the bundle containing the message
+ * @param severity the severity of the message
*
* @return the {@link LogMessage} instance
*/
@@ -259,14 +232,10 @@ public abstract class PlcService implements PlcListener {
/**
* Creates a {@link LogMessage} for the given fields
*
- * @param addressKey
- * the address for the key
- * @param bundle
- * the bundle containing the message
- * @param severity
- * the severity of the message
- * @param state
- * the state of the message
+ * @param addressKey the address for the key
+ * @param bundle the bundle containing the message
+ * @param severity the severity of the message
+ * @param state the state of the message
*
* @return the {@link LogMessage} instance
*/
@@ -280,12 +249,9 @@ public abstract class PlcService implements PlcListener {
/**
* Creates a {@link LogMessage} for the given fields
*
- * @param i18nKey
- * the key of the message
- * @param bundle
- * the bundle containing the message
- * @param severity
- * the severity of the message
+ * @param i18nKey the key of the message
+ * @param bundle the bundle containing the message
+ * @param severity the severity of the message
*
* @return the {@link LogMessage} instance
*/
@@ -296,14 +262,10 @@ public abstract class PlcService implements PlcListener {
/**
* Creates a {@link LogMessage} for the given fields
*
- * @param i18nKey
- * the key of the message
- * @param bundle
- * the bundle containing the message
- * @param severity
- * the severity of the message
- * @param state
- * the state of the message
+ * @param i18nKey the key of the message
+ * @param bundle the bundle containing the message
+ * @param severity the severity of the message
+ * @param state the state of the message
*
* @return the {@link LogMessage} instance
*/
@@ -317,14 +279,13 @@ public abstract class PlcService implements PlcListener {
/**
* Sends the given {@link LogMessage} to the remote listener
*
- * @param logMessage
- * the message to send
+ * @param logMessage the message to send
*/
protected void sendMsg(LogMessage logMessage) {
switch (logMessage.getSeverity()) {
- case Info, Notification -> logger.info(logMessage.toString());
- case Warning -> logger.warn(logMessage.toString());
- case Error, Exception -> logger.error(logMessage.toString());
+ case Info, Notification -> logger.info(logMessage.toString());
+ case Warning -> logger.warn(logMessage.toString());
+ case Error, Exception -> logger.error(logMessage.toString());
}
this.plcHandler.sendMsg(logMessage);
}
@@ -332,8 +293,7 @@ public abstract class PlcService implements PlcListener {
/**
* Disables a message with the given {@link Locator}
*
- * @param locator
- * the locator of the message
+ * @param locator the locator of the message
*/
protected void disableMsg(Locator locator) {
logger.info("Disabling message for locator " + locator);
@@ -343,10 +303,8 @@ public abstract class PlcService implements PlcListener {
/**
* Causes the {@link PlcAddress} for the given resource and action to be sent as a telegram with its default value
*
- * @param resource
- * the resource
- * @param action
- * the action
+ * @param resource the resource
+ * @param action the action
*/
protected void send(String resource, String action) {
this.plcHandler.send(resource, action);
@@ -355,12 +313,9 @@ public abstract class PlcService implements PlcListener {
/**
* Causes the {@link PlcAddress} for the given resource and action to be sent as a telegram with the given value
*
- * @param resource
- * the resource
- * @param action
- * the action
- * @param value
- * the value to send with the {@link PlcAddress}
+ * @param resource the resource
+ * @param action the action
+ * @param value the value to send with the {@link PlcAddress}
*/
protected void send(String resource, String action, Object value) {
this.plcHandler.send(resource, action, value);
@@ -369,12 +324,9 @@ public abstract class PlcService implements PlcListener {
/**
* Notifies listeners on the {@link PlcAddress} for the given resource and action, of the new value
*
- * @param resource
- * the resource
- * @param action
- * the action
- * @param value
- * the value to notify the listeners with
+ * @param resource the resource
+ * @param action the action
+ * @param value the value to notify the listeners with
*/
protected void notify(String resource, String action, Object value) {
this.plcHandler.notify(resource, action, value);
@@ -383,8 +335,7 @@ public abstract class PlcService implements PlcListener {
/**
* Runs the given {@link PrivilegedRunnable} as the agent user
*
- * @param runnable
- * the runnable to run
+ * @param runnable the runnable to run
*/
protected void run(PrivilegedRunnable runnable) throws Exception {
this.container.getPrivilegeHandler().runAsAgent(runnable);
@@ -393,10 +344,8 @@ public abstract class PlcService implements PlcListener {
/**
* Runs the given {@link PrivilegedRunnableWithResult} as the agent user, returning a value as the result
*
- * @param runnable
- * the runnable to run
- * @param
- * the type of object being returned in the runnable
+ * @param runnable the runnable to run
+ * @param the type of object being returned in the runnable
*
* @return the result of the runnable
*/
@@ -407,10 +356,8 @@ public abstract class PlcService implements PlcListener {
/**
* Opens a new {@link StrolchTransaction} with the given {@link PrivilegeContext}
*
- * @param ctx
- * the {@link PrivilegeContext}
- * @param readOnly
- * true for the TX to be read only
+ * @param ctx the {@link PrivilegeContext}
+ * @param readOnly true for the TX to be read only
*
* @return the new TX to be used in a try-with-resource block
*/
@@ -438,9 +385,8 @@ public abstract class PlcService implements PlcListener {
/**
* Delays the execution of the given runnable by the given delay in milliseconds. Subsequent calls with the
- * given
- * {@link PlcAddress} will cancel any previous calls with the same address, delaying the execution again by the
- * given amount of time.
+ * given {@link PlcAddress} will cancel any previous calls with the same address, delaying the execution again by
+ * the given amount of time.
*
* This methods is used to handle hardware where the bits change often, before resting at a new state. E.g. a
* light barrier where it might toggle between true and false a few times, before staying true when the light
@@ -458,8 +404,7 @@ public abstract class PlcService implements PlcListener {
/**
* Submits the given runnable for asynchronous execution
*
- * @param runnable
- * the runnable to execute asynchronously
+ * @param runnable the runnable to execute asynchronously
*/
protected void async(Runnable runnable) {
getExecutor().submit(() -> {
@@ -474,12 +419,9 @@ public abstract class PlcService implements PlcListener {
/**
* Delay the execution of the given {@link Runnable} by the given delay
*
- * @param runnable
- * the runnable to delay
- * @param delay
- * the time to delay
- * @param delayUnit
- * the unit of the time to delay
+ * @param runnable the runnable to delay
+ * @param delay the time to delay
+ * @param delayUnit the unit of the time to delay
*
* @return a future to cancel the executor before execution
*/
@@ -496,12 +438,9 @@ public abstract class PlcService implements PlcListener {
/**
* Delay the execution of the given {@link PrivilegedRunnable} by the given delay
*
- * @param runnable
- * the runnable to delay
- * @param delay
- * the time to delay
- * @param delayUnit
- * the unit of the time to delay
+ * @param runnable the runnable to delay
+ * @param delay the time to delay
+ * @param delayUnit the unit of the time to delay
*
* @return a future to cancel the executor before execution
*/
@@ -518,14 +457,10 @@ public abstract class PlcService implements PlcListener {
/**
* Submit the given {@link Runnable} for repeated execution
*
- * @param runnable
- * the runnable to delay
- * @param initialDelay
- * the initial delay
- * @param period
- * the delay between subsequent executions
- * @param delayUnit
- * the unit of the time to delay
+ * @param runnable the runnable to delay
+ * @param initialDelay the initial delay
+ * @param period the delay between subsequent executions
+ * @param delayUnit the unit of the time to delay
*
* @return a future to cancel the executor before execution
*/
@@ -543,14 +478,10 @@ public abstract class PlcService implements PlcListener {
/**
* Submit the given {@link PrivilegedRunnable} for repeated execution
*
- * @param runnable
- * the runnable to delay
- * @param initialDelay
- * the initial delay
- * @param period
- * the delay between subsequent executions
- * @param delayUnit
- * the unit of the time to delay
+ * @param runnable the runnable to delay
+ * @param initialDelay the initial delay
+ * @param period the delay between subsequent executions
+ * @param delayUnit the unit of the time to delay
*
* @return a future to cancel the executor before execution
*/
@@ -568,14 +499,10 @@ public abstract class PlcService implements PlcListener {
/**
* Submit the given {@link Runnable} for repeated execution
*
- * @param runnable
- * the runnable to delay
- * @param initialDelay
- * the initial delay
- * @param period
- * the delay between subsequent executions
- * @param delayUnit
- * the unit of the time to delay
+ * @param runnable the runnable to delay
+ * @param initialDelay the initial delay
+ * @param period the delay between subsequent executions
+ * @param delayUnit the unit of the time to delay
*
* @return a future to cancel the executor before execution
*/
@@ -593,14 +520,10 @@ public abstract class PlcService implements PlcListener {
/**
* Submit the given {@link PrivilegedRunnable} for repeated execution
*
- * @param runnable
- * the runnable to delay
- * @param initialDelay
- * the initial delay
- * @param period
- * the delay between subsequent executions
- * @param delayUnit
- * the unit of the time to delay
+ * @param runnable the runnable to delay
+ * @param initialDelay the initial delay
+ * @param period the delay between subsequent executions
+ * @param delayUnit the unit of the time to delay
*
* @return a future to cancel the executor before execution
*/
@@ -618,8 +541,7 @@ public abstract class PlcService implements PlcListener {
/**
* Notifies the caller of one of the async, or schedule methods that the execution of a runnable failed
*
- * @param e
- * the exception which occurred
+ * @param e the exception which occurred
*/
protected void handleFailedAsync(Exception e) {
logger.error("Failed to execute " + getClass().getSimpleName(), e);