Skip to content

Commit

Permalink
Merge pull request #36 from ChristopheCVB/develop
Browse files Browse the repository at this point in the history
fix: DataHelper.getDataId when Data has stateId
  • Loading branch information
ChristopheCVB authored Jul 24, 2021
2 parents 282f51c + 5718f27 commit 7005921
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ allprojects {

ext.versionMajor = 8
ext.versionMinor = 0
ext.versionPatch = 0
ext.versionPatch = 1

ext.isRelease = System.getenv('IS_RELEASE') == 'YES'

Expand Down

0 comments on commit 7005921

Please sign in to comment.