Class ExtensionFunction
- java.lang.Object
-
- com.inductiveautomation.vision.api.client.components.model.ExtensionFunction
-
public class ExtensionFunction extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ExtensionFunction(boolean enabled, java.lang.String script)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
java.lang.String
getScript()
static <T> T
invoke(ExtensibleComponent self, LoggerEx log, java.lang.String methodName, java.lang.Class<T> returnType, T defaultValue, java.lang.Object... args)
Helper function to invoke an extension function.static boolean
isDefined(ExtensibleComponent self, java.lang.String methodName)
Tests whether or not the given extensible component has an enabled extension function for the given method nameboolean
isEnabled()
-
-
-
Method Detail
-
isEnabled
public boolean isEnabled()
-
getScript
public java.lang.String getScript()
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
isDefined
public static boolean isDefined(ExtensibleComponent self, java.lang.String methodName)
Tests whether or not the given extensible component has an enabled extension function for the given method name
-
invoke
public static <T> T invoke(ExtensibleComponent self, LoggerEx log, java.lang.String methodName, java.lang.Class<T> returnType, T defaultValue, java.lang.Object... args)
Helper function to invoke an extension function.- Parameters:
self
- The component that is invokinglog
- A logger to log any errors to. This function never throws an exception. Any problems are logged to this logger and the default will be returned.methodName
- The name of the extension function. Must match the associated ExtensionFunctionDescriptor's method name.returnType
- The type to coerce the script's return value into. For functions that don't need to return anything, use Void.classdefaultValue
- The default return value. This will be returned if this extension function isn't implemented on self.args
- Arguments to pass to the function.- Returns:
- whatever value the extensible function returned, or defaultValue if there was no extension function defined
-
-