package org.kurento.modulecreator.codegen.function;

import java.util.ArrayList;
import java.util.List;

import org.kurento.modulecreator.definition.RemoteClass;
import org.kurento.modulecreator.definition.Return;
import org.kurento.modulecreator.definition.TypeRef;

import freemarker.ext.beans.StringModel;
import freemarker.template.TemplateMethodModelEx;
import freemarker.template.TemplateModelException;

public class TypeHierarchy implements TemplateMethodModelEx {

  @Override
  public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException {

    Object type = arguments.get(0);

    if (type instanceof StringModel) {
      type = ((StringModel) type).getWrappedObject();
      if (type instanceof Return) {
        type = ((Return) type).getType();
      }
    }

    if (type instanceof TypeRef) {
      type = ((TypeRef) type).getType();
    }

    if (type instanceof RemoteClass) {
      RemoteClass remoteClass = (RemoteClass) type;
      TypeRef parent = remoteClass.getExtends();
      ArrayList<String> list = new ArrayList<String>();

      while (parent != null) {
        String moduleName = parent.getModule().getName();

        if (moduleName == "core" || moduleName == "elements" || moduleName == "filters") {
          moduleName = "kurento";
        }

        if (moduleName == null) {
          moduleName = "";
        } else if (!moduleName.isEmpty()) {
          moduleName += ".";
        }

        list.add(moduleName + parent.getName());

        if (parent.getType() instanceof RemoteClass) {
          parent = ((RemoteClass) parent.getType()).getExtends();
        }
      }

      return list;
    } else {
      throw new TemplateModelException("Received invalid type, only RemoteClass is accepted");
    }

  }
}
@@ -1202,17 +1202,25 @@
  == 
-%22core%22 %7C%7C
+null) %7B%0A         
  mod
@@ -1232,126 +1232,138 @@
 me =
-=
  %22
-elements%22 %7C%7C moduleName == %22filters%22) %7B%0A          moduleName = %22kurento%22;%0A        %7D%0A%0A        if (moduleName == null
+%22;%0A        %7D%0A%0A        if (moduleName.equals(%22core%22) %7C%7C moduleName.equals(%22elements%22)%0A            %7C%7C moduleName.equals(%22filters%22)
 ) %7B%0A
@@ -1378,32 +1378,39 @@
   moduleName = %22
+kurento
 %22;%0A        %7D els
@@ -1405,21 +1405,25 @@
        %7D
- else
+%0A%0A       
  if (!mo

Compare string correctly