| package chip.clusterinfo; |
| |
| import chip.devicecontroller.ChipClusters.BaseChipCluster; |
| import java.util.Map; |
| import java.util.function.Supplier; |
| |
| /** |
| * InteractionInfo has a functional interface to invoke arbitrary interaction based on cluster, |
| * callback and a map of arguments, a Supplier that provides {@link DelegatedClusterCallback}, and |
| * maps the parameter and commandParametersInfo. |
| */ |
| public class InteractionInfo { |
| public ClusterCommandFunction commandFunction; |
| private Supplier<DelegatedClusterCallback> commandCallbackSupplier; |
| private Map<String, CommandParameterInfo> commandParameters; |
| |
| public InteractionInfo( |
| ClusterCommandFunction commandFunction, |
| Supplier<DelegatedClusterCallback> commandCallbackSupplier, |
| Map<String, CommandParameterInfo> commandParameters) { |
| this.commandFunction = commandFunction; |
| this.commandCallbackSupplier = commandCallbackSupplier; |
| this.commandParameters = commandParameters; |
| } |
| |
| public ClusterCommandFunction getCommandFunction() { |
| return commandFunction; |
| } |
| |
| public Supplier<DelegatedClusterCallback> getCommandCallbackSupplier() { |
| return commandCallbackSupplier; |
| } |
| |
| public Map<String, CommandParameterInfo> getCommandParameters() { |
| return commandParameters; |
| } |
| |
| /** |
| * The functional interface provides a uniform way to invoke commands through invokeCommand |
| * function. In ClusterInfoMapping, each ClusterCommandFunction was generated using the intended |
| * function. By using lambda function, the app component only needs to have cluster, callback, |
| * commandArguments to execute the correct function. |
| */ |
| @FunctionalInterface |
| public interface ClusterCommandFunction { |
| void invokeCommand( |
| BaseChipCluster cluster, Object callback, Map<String, Object> commandArguments); |
| } |
| } |