package com.redhat.ceylon.compiler.java.runtime.metamodel;

import ceylon.language.Sequential;
import ceylon.language.metamodel.Module$impl;
import ceylon.language.metamodel.Package;

import com.redhat.ceylon.compiler.java.metadata.Ignore;
import com.redhat.ceylon.compiler.java.metadata.TypeInfo;
import com.redhat.ceylon.compiler.java.runtime.model.ReifiedType;
import com.redhat.ceylon.compiler.java.runtime.model.TypeDescriptor;

public class Module implements ceylon.language.metamodel.Module, ReifiedType{

    @Ignore
    public static final TypeDescriptor $TypeDescriptor = TypeDescriptor.klass(Module.class);
    private com.redhat.ceylon.compiler.typechecker.model.Module declaration;
    
    public Module(com.redhat.ceylon.compiler.typechecker.model.Module declaration) {
        this.declaration = declaration;
    }

    @Override
    @Ignore
    public Module$impl $ceylon$language$metamodel$Module$impl() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    @TypeInfo("ceylon.language::Sequential<ceylon.language.metamodel::Package>")
    public Sequential<? extends Package> getMembers() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    @TypeInfo("ceylon.language::String")
    public String getName() {
        return declaration.getNameAsString();
    }

    @Override
    @TypeInfo("ceylon.language::String")
    public String getVersion() {
        return declaration.getVersion();
    }

    @Ignore
    @Override
    public TypeDescriptor $getType() {
        return $TypeDescriptor;
    }
}

@@ -53,16 +53,40 @@
 model;%0A%0A
+import java.util.List;%0A%0A
 import c
@@ -112,16 +112,16 @@
 ential;%0A
-
 import c
@@ -201,16 +201,61 @@
 ckage;%0A%0A
+import com.redhat.ceylon.compiler.java.Util;%0A
 import c
@@ -753,24 +753,66 @@
 eclaration;%0A
+    private Sequential%3CPackage%3E packages;%0A
     %0A    pub
@@ -1265,39 +1265,551 @@
  // 
-TODO Auto-generated method stub
+no need to synchronise as concurrent invocations should get the same array back%0A        if(this.packages == null)%7B%0A            List%3Ccom.redhat.ceylon.compiler.typechecker.model.Package%3E modelPackages = declaration.getAllPackages();%0A            Package%5B%5D packages = new Package%5BmodelPackages.size()%5D;%0A            for(int i=0;i%3Cpackages.length;i++)%7B%0A                packages%5Bi%5D = Metamodel.getOrCreateMetamodel(modelPackages.get(i));%0A            %7D%0A            this.packages = Util.sequentialInstance(Package.$TypeDescriptor, packages);%0A        %7D
 %0A   
@@ -1812,36 +1812,45 @@
 %0A        return 
-null
+this.packages
 ;%0A    %7D%0A%0A    @Ov

implement Module.members #226