You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2018/10/26 20:35:18 UTC

[incubator-plc4x] 02/06: [plc4j-opm] added sanity checks for getter having no parameters.

This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git

commit c947721355042ca76d634e3ac9b14fef26bcd1af
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Fri Oct 26 22:02:56 2018 +0200

    [plc4j-opm] added sanity checks for getter having no parameters.
---
 .../src/main/java/org/apache/plc4x/java/opm/PlcEntityManager.java   | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/plc4j/utils/opm/src/main/java/org/apache/plc4x/java/opm/PlcEntityManager.java b/plc4j/utils/opm/src/main/java/org/apache/plc4x/java/opm/PlcEntityManager.java
index f42461f..aa51f7b 100644
--- a/plc4j/utils/opm/src/main/java/org/apache/plc4x/java/opm/PlcEntityManager.java
+++ b/plc4j/utils/opm/src/main/java/org/apache/plc4x/java/opm/PlcEntityManager.java
@@ -218,6 +218,9 @@ public class PlcEntityManager {
         LOGGER.trace("Invoked method {} on connected PlcEntity {}", m.getName(), that);
 
         if (m.getName().startsWith("get")) {
+            if (m.getParameterCount() > 0) {
+                throw new OPMException("Only getter with no arguments are supported");
+            }
             // Fetch single value
             LOGGER.trace("Invoked method {} is getter, trying to find annotated field and return requested value",
                 m.getName());
@@ -225,6 +228,9 @@ public class PlcEntityManager {
         }
 
         if (m.getName().startsWith("is") && (m.getReturnType() == boolean.class || m.getReturnType() == Boolean.class)) {
+            if (m.getParameterCount() > 0) {
+                throw new OPMException("Only getter with no arguments are supported");
+            }
             // Fetch single value
             LOGGER.trace("Invoked method {} is boolean flag method, trying to find annotated field and return requested value",
                 m.getName());