pip_services3_commons.reflect.MethodReflector module
pip_services3_commons.reflect.MethodReflector
Method reflector implementation
- copyright
Conceptual Vision Consulting LLC 2018-2019, see AUTHORS for more details.
- license
MIT, see LICENSE for more details.
-
class
pip_services3_commons.reflect.MethodReflector.
MethodReflector
Bases:
object
Helper class to perform method introspection and dynamic invocation. This class has symmetric implementation across all languages supported by Pip.Services toolkit and used to support dynamic data processing.
Because all languages have different casing and case sensitivity __rules, this MethodReflector treats all method names as case insensitive.
Example:
myObj = new MyObject() methods = MethodReflector.get_method_names() MethodReflector.has_method(myObj, "myMethod") MethodReflector.invoke_method(myObj, "myMethod", 123)
-
static
get_method_names
(obj: Any) → List[str] Gets names of all methods implemented in specified object.
- Parameters
obj – an object to introspect.
- Returns
a list with method names.
-
static
has_method
(obj: Any, name: str) → bool Checks if object has a method with specified name.
- Parameters
obj – an object to introspect.
name – a name of the method to check.
- Returns
true if the object has the method and false if it doesn’t.
-
static
invoke_method
(obj: Any, name: str, *args: Any) → Any Invokes an object method by its name with specified parameters.
- Parameters
obj – an object to invoke.
name – a name of the method to invoke.
args – a list of method arguments.
- Returns
the result of the method invocation or null if method returns void.
-
static