Sha256: 859f007892c6ccd0b302416b776753ff29d691529fd75a7f58a446dd8ccbbb31

Contents?: true

Size: 1.01 KB

Versions: 22

Compression:

Stored size: 1.01 KB

Contents

from inspect import signature

from javonet.core.handler.CommandHandler.AbstractCommandHandler import *


class CreateClassInstanceHandler(AbstractCommandHandler):
    def __init__(self):
        self._required_parameters_count = 1

    def process(self, command):
        try:

            if len(command.payload) < self._required_parameters_count:
                raise Exception("CreateClassInstanceHandler parameters mismatch!")
            clazz = command.payload[0]
            if len(command.payload) > 1:
                method_arguments = command.payload[1:]
                sig = signature(clazz)
                if len(sig.parameters) != len(method_arguments):
                    raise Exception("Number of arguments for create class instance are not matching!")
                return clazz(*method_arguments)
            return clazz()
        except Exception as e:
            exc_type, exc_value = type(e), e
            new_exc = exc_type(exc_value).with_traceback(e.__traceback__)
            raise new_exc from None

Version data entries

22 entries across 11 versions & 1 rubygems

Version Path
javonet-ruby-sdk-2.1.1 lib/javonet-ruby-sdk/Binaries/Python/Linux/X64/javonet/core/handler/CommandHandler/CreateClassInstanceHandler.py
javonet-ruby-sdk-2.1.1 lib/javonet-ruby-sdk/Binaries/Python/MacOs/X64/javonet/core/handler/CommandHandler/CreateClassInstanceHandler.py