Class SMethodImpl<T>

  • All Implemented Interfaces:
    SExecutable, SMethod<T>, SElement, SNamedElement

    public final class SMethodImpl<T>
    extends Object
    implements SMethod<T>
    As for 3.2 -- we still have the behavior language which allows several methods with identical signature. Moreover it urges us to point to the overridden method explicitly. Pro & contra 1. The good part is a possibility to resolve a simple case: abstract I1#foo(); abstract I2#foo(); concept C extends I1, I2. We are able to deliver up two separate methods (with the same java signature) overriding each foo separately. 2. The bad part is that a user of the system can easily make a mess: methods are resolved by id. Also the generated code is forced to make the most of id, because string name resolving is simply not enough here. Besides it is not that easy to override method -- one needs to reference the method he wants to override. Plan for 3.3: 1. Make the 'overrides' reference optional: simply rename all the methods so that overridden_method.name.equals(this.name) 'overrides' is required only two virtual method hierarchies clash in the concept. 2. Grant the 'virtual' keyword new semantics: automatic method resolve must happen in the case of virtual methods with overridden method == null. 3. Give out an error about methods' name collision, forbid generation if that is the case. Only there is no conflict for virtual methods' names throughout in the concept hierarchy it might be possible to resolve two overriding methods by name.
    • Method Detail

      • create

        public static <T> SMethod<T> create​(@NotNull
                                            String methodName,
                                            @NotNull
                                            SModifiers modifiers,
                                            @NotNull
                                            SAbstractType returnType,
                                            @NotNull
                                            SAbstractConcept concept,
                                            @NotNull
                                            SMethodId id,
                                            @NotNull
                                            BehaviorRegistry registry,
                                            List<SParameter> parameters)
        NB: there is a cozy SMethodBuilder to create SMethod
        Type Parameters:
        T - -- parametrized by return type
        Parameters:
        methodName - -- usual methodName
        modifiers - -- could be virtual or (and) static. @see SMethodModifiers
        returnType - -- return type
        concept - -- the concept, which contains the method declaration. we need it to distinguish two identically named non-virtual methods in the parent and the child classes.
        parameters - -- the types of method's arguments
        id - -- method string id which must uniquely identify the method throughout the concept hierarchy. NB: for the virtual methods which have the same base method, the id must be the same.
        registry - -- BehaviorRegistry to get the mapping concept <-> behavior descriptor
        Returns:
        new SMethod
      • invoke

        public T invoke​(@Nullable
                        SNode operand,
                        Object... parameters)
        Description copied from interface: SMethod
        invokes the method (trying to resolve the right method on runtime if it is virtual) essentially invokes the #invoke0 method with the concept of the operand
        Specified by:
        invoke in interface SMethod<T>
      • invoke

        public T invoke​(@Nullable
                        SAbstractConcept operand,
                        Object... parameters)
        Description copied from interface: SMethod
        invokes the method in the case it is static (trying to resolve the right method on runtime if it is virtual)
        Specified by:
        invoke in interface SMethod<T>
      • invokeSpecial

        public T invokeSpecial​(@Nullable
                               SNode operand,
                               Object... parameters)
        Description copied from interface: SMethod
        invokes private method (no dynamic method resolve) generated from the super non-virtual invocations or the super<> invocations
        Specified by:
        invokeSpecial in interface SMethod<T>
      • invokeSuper

        public T invokeSuper​(@Nullable
                             SNode operand,
                             @NotNull
                             SAbstractConcept concept,
                             Object... parameters)
        Description copied from interface: SMethod
        invokes virtual method looking for the ancestors of the node's concept (dynamic method resolve)
        Specified by:
        invokeSuper in interface SMethod<T>
        concept - is the concept from which the #invokeSuper is intended to be executed
      • isAbstract

        public boolean isAbstract()
        Description copied from interface: SMethod
        abstract => virtual
        Specified by:
        isAbstract in interface SMethod<T>
        Returns:
        true iff the method has an abstract modifier
      • getConcept

        @NotNull
        public SAbstractConcept getConcept()
        Description copied from interface: SExecutable
        SExecutable must belong to some concept For example in the case of SMethod the concept is the concept where the method is declared
        Specified by:
        getConcept in interface SExecutable
        Returns:
        the concept which this executable belongs to
      • getId

        @NotNull
        public SMethodId getId()
        Specified by:
        getId in interface SMethod<T>
        Returns:
        SMethodId which uniquely identifies the behavior methods within the concept NB: all inherited methods count as well However the id of the virtual method and its overrides is the same (!)
      • getName

        @NotNull
        public String getName()
        Description copied from interface: SNamedElement
        Presentation of the element for an end-user. Unlike identity, the name is deemed user-friendly and shall not be used for persistence.
        Specified by:
        getName in interface SNamedElement
        Returns:
        name of the meta element
      • isPublic

        public boolean isPublic()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object