package blitzEdit.core;

import java.util.TreeMap;
import java.util.Collection;
import java.util.ArrayList;

public class BlueprintContainer 
{
	
	
	public void setBlueprint(ComponentBlueprint blueprint)
	{
		_blueprints.put(blueprint.getType(), blueprint);
	}
	
	// Checks if blueprints with same type
	// are identical.
	public boolean checkBlueprint(ComponentBlueprint blueprint)
	{
		if (_blueprints.get(blueprint.getType()).equals(blueprint))
			return true;
		return false;
	}
	
	// compares all blueprints to those in the desginated Collection
	// returns all blueprints which have changed.
	public ArrayList<ComponentBlueprint> compareAll(Collection<ComponentBlueprint> cbs)
	{
		ArrayList<ComponentBlueprint> ret = new ArrayList<ComponentBlueprint>();
		
		for (ComponentBlueprint cb : cbs)
		{
			if (!_blueprints.containsKey(cb.getType())
				|| _blueprints.get(cb.getType()).hashCode() != cb.hashCode() )
				ret.add(cb);
		}
		if (ret.isEmpty())
			return null;
		return ret;
	}
	
	// returns blueprint for the designated type
	public ComponentBlueprint getBlueprint(String type)
	{
		return _blueprints.get(type);
	}
	
	public TreeMap<String, ComponentBlueprint> getBlueprints()
	{
		return new TreeMap<String, ComponentBlueprint>(_blueprints);
	}
	
	// returns instance (singleton)
	public static BlueprintContainer get()
	{
		if (_instance == null)
			_instance = new BlueprintContainer();
		return _instance;
	}
	
	private BlueprintContainer()
	{
		_blueprints = new TreeMap<String, ComponentBlueprint>();
	}
	
	private static BlueprintContainer _instance;
	private TreeMap<String, ComponentBlueprint> _blueprints;
}

@@ -138,18 +138,109 @@
 ner %0A%7B%0A%09
-%0A%09
+// put new Blueprint in container.%0A%09// the old one will be overwritten, if already existing. 
 %0A%09public
@@ -975,36 +975,18 @@
 ()).
-hashCode() != cb.hashCode() 
+equals(cb)
 )%0A%09%09

Update BlueprintContainer.java