From 5718f27744a23b132d7a3cb65a024f22e8d6a977 Mon Sep 17 00:00:00 2001 From: Christophe Carvalho Vilas-Boas Date: Sat, 24 Jul 2021 15:58:34 +0200 Subject: [PATCH] fix: DataHelper.getDataId when Data has stateId --- .../touchportal/helpers/DataHelper.java | 24 +++++++++++++++---- build.gradle | 2 +- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Helpers/src/main/java/com/christophecvb/touchportal/helpers/DataHelper.java b/Helpers/src/main/java/com/christophecvb/touchportal/helpers/DataHelper.java index 0c2d29f..3fd5370 100644 --- a/Helpers/src/main/java/com/christophecvb/touchportal/helpers/DataHelper.java +++ b/Helpers/src/main/java/com/christophecvb/touchportal/helpers/DataHelper.java @@ -20,14 +20,12 @@ package com.christophecvb.touchportal.helpers; -import com.christophecvb.touchportal.annotations.Action; -import com.christophecvb.touchportal.annotations.Category; -import com.christophecvb.touchportal.annotations.Connector; -import com.christophecvb.touchportal.annotations.Data; +import com.christophecvb.touchportal.annotations.*; import javax.lang.model.element.Element; import java.lang.reflect.Method; import java.lang.reflect.Parameter; +import java.util.Arrays; /** * Touch Portal Plugin Data Helper @@ -126,7 +124,23 @@ public static String getDataId(Class pluginClass, Method method, Parameter me if (methodParameter.isAnnotationPresent(Data.class)) { Data data = methodParameter.getAnnotation(Data.class); - dataId = DataHelper._getDataId(ActionHelper.getActionId(pluginClass, method), data.id().isEmpty() ? methodParameter.getName() : data.id()); + if (!data.stateId().isEmpty()) { + String categoryId = null; + if (method.isAnnotationPresent(Action.class)) { + Action action = method.getAnnotation(Action.class); + categoryId = action.categoryId(); + } + else if (method.isAnnotationPresent(Connector.class)) { + Connector connector = method.getAnnotation(Connector.class); + categoryId = connector.categoryId(); + } + if (categoryId != null) { + dataId = StateHelper.getStateId(pluginClass, categoryId, data.stateId()); + } + } + else { + dataId = DataHelper._getDataId(ActionHelper.getActionId(pluginClass, method), data.id().isEmpty() ? methodParameter.getName() : data.id()); + } } return dataId; diff --git a/build.gradle b/build.gradle index 3d25991..1f0715e 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ allprojects { ext.versionMajor = 8 ext.versionMinor = 0 -ext.versionPatch = 0 +ext.versionPatch = 1 ext.isRelease = System.getenv('IS_RELEASE') == 'YES'