/*
   Copyright 2018 Volker Berlin (i-net software)

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

*/
package de.inetsoftware.jwebassembly.module;

import javax.annotation.Nonnull;

import de.inetsoftware.classparser.Member;

/**
 * Described the name of WebAssembly function.
 * 
 * @author Volker Berlin
 *
 */
public class FunctionName {

    /**
     * The name in the WebAssembly.
     */
    @Nonnull
    public final String fullName;

    /**
     * The Java signature which is used in Java byte code to reference the method call.
     */
    @Nonnull
    public final String signatureName;

    /**
     * Create a new instance from the given reference in the ConstantPool or parsed method.
     * 
     * @param methodOrField
     *            the Java method
     */
    FunctionName( @Nonnull Member methodOrField ) {
        String methodName = methodOrField.getName();
        String className = methodOrField.getClassName();
        fullName = className + '.' + methodName;
        signatureName = fullName + methodOrField.getType();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public int hashCode() {
        return signatureName.hashCode();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean equals( Object obj ) {
        if( this == obj ) {
            return true;
        }
        if( obj == null ) {
            return false;
        }
        if( getClass() != obj.getClass() ) {
            return false;
        }
        FunctionName other = (FunctionName)obj;
        return signatureName.equals( other.signatureName );
    }
}

@@ -841,16 +841,109 @@
 Name %7B%0A%0A
+    /**%0A     * The Java class name.%0A     */%0A    @Nonnull%0A    public final String className;%0A%0A
     /**%0A
@@ -978,16 +978,16 @@
 sembly.%0A
-
      */%0A
@@ -1187,24 +1187,110 @@
 atureName;%0A%0A
+    /**%0A     * The signature%0A     */%0A    @Nonnull%0A    public final String signature;%0A%0A
     /**%0A    
@@ -1519,27 +1519,392 @@
     
-String methodName =
+this( methodOrField, methodOrField.getType() );%0A    %7D%0A%0A    /**%0A     * Create a new instance from the given reference in the ConstantPool and a special signature.%0A     * %0A     * @param methodOrField%0A     *            the Java method%0A     * @param signature%0A     *            the Java signature%0A     */%0A    FunctionName( @Nonnull Member methodOrField, String signature ) %7B%0A        this(
  met
@@ -1921,71 +1921,438 @@
 .get
+Class
 Name(
+), methodOrField.getName(), signature 
 );%0A    
+%7D%0A%0A
     
-String className = methodOrField.getClassName()
+/**%0A     * Create a new instance from the given values%0A     * %0A     * @param className%0A     *            the Java class name%0A     * @param methodName%0A     *            the Java method name%0A     * @param signature%0A     *            the Java signature%0A     */%0A    FunctionName( String className, String methodName, String signature ) %7B%0A        this.className = className
 ;%0A  
@@ -2357,16 +2357,21 @@
         
+this.
 fullName
@@ -2411,16 +2411,21 @@
         
+this.
 signatur
@@ -2443,39 +2443,61 @@
 lName + 
-methodOrField.getType()
+signature;%0A        this.signature = signature
 ;%0A    %7D%0A

improve the constructor of FunctionName