You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2020/03/11 10:02:08 UTC

[plc4x] 01/02: - Made the SimpleValue allow using the getIndex method if the index is 0

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

cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit 59795ad56e739b083061a68b27e3bca211c5e211
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Wed Mar 11 11:01:22 2020 +0100

    - Made the SimpleValue allow using the getIndex method if the index is 0
---
 .../org/apache/plc4x/java/api/value/PlcSimpleValue.java     | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcSimpleValue.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcSimpleValue.java
index d51bdaf..5b784fd 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcSimpleValue.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/value/PlcSimpleValue.java
@@ -54,4 +54,17 @@ public abstract class PlcSimpleValue<T> extends PlcValueAdapter {
         return isNullable && value == null;
     }
 
+    /**
+     * Convenience method to simplify accessing items with a list syntax.
+     * @param i item number
+     * @return if i == 0 returns itself, otherwise throws an exception.
+     */
+    @Override
+    public PlcValue getIndex(int i) {
+        if(i == 0) {
+            return this;
+        }
+        return super.getIndex(i);
+    }
+
 }