package org.minimalj.metamodel.model;

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

// TODO rename all MjXy classes to MetaXy
public class MjModel {

	public final List<MjEntity> entities = new ArrayList<>();
	
	public MjModel(Class<?>... classes) {
		for (Class<?> clazz : classes) {
			new MjEntity(this, clazz);
		}
	}

	public void addEntity(MjEntity mjEntity) {
		if (!entities.contains(mjEntity)) {
			entities.add(mjEntity);
		}
	}

	public MjEntity getEntity(Class<?> clazz) {
		for (MjEntity entity : entities) {
			if (entity.name.equals(clazz.getName())) {
				return entity;
			}
		}
		return new MjEntity(this, clazz);
	}
	
}

@@ -93,49 +93,42 @@
 %0D%0A%0D%0A
-// TODO rename all MjXy classes to MetaXy
+import org.minimalj.model.Model;%0D%0A
 %0D%0Apu
@@ -210,16 +210,89 @@
 st%3C%3E();%0D
+%0A%0D%0A%09public MjModel(Model model) %7B%0D%0A%09%09this(model.getEntityClasses());%0D%0A%09%7D%0D
 %0A%09%0D%0A%09pub

use Model interface