package org.pfaa.geologica.registration;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.pfaa.chemica.model.Chemical;
import org.pfaa.geologica.GeoMaterial;
import org.pfaa.geologica.processing.Mineral;
import org.pfaa.geologica.processing.OreMineral;

public class RawMaterials {
	private static Map<Chemical,OreMineral> oreCompoundToMineral = new HashMap<Chemical, OreMineral>();
	private static Map<OreMineral,List<GeoMaterial>> oreMineralToGeoMaterials = new HashMap<OreMineral,List<GeoMaterial>>();
	
	public static void register(OreMineral mineral) {
		oreCompoundToMineral.put(mineral.getConcentrate(), mineral);
	}
	
	public static void register(GeoMaterial material) {
		Mineral concentrate = material.getOreConcentrate();
		if (concentrate instanceof OreMineral) {
			OreMineral mineral = (OreMineral) concentrate;
			List<GeoMaterial> materials = oreMineralToGeoMaterials.get(mineral);
			if (materials == null) {
				materials = new ArrayList<GeoMaterial>();
				oreMineralToGeoMaterials.put(mineral, materials);
			}
			materials.add(material);
		}
	}
	
	public static OreMineral get(Chemical chemical) {
		return oreCompoundToMineral.get(chemical);
	}
	
	public static List<GeoMaterial> get(OreMineral mineral) {
		return oreMineralToGeoMaterials.get(mineral);
	}
}

@@ -195,21 +195,32 @@
 faa.
-geologica.Geo
+chemica.model.Industrial
 Mate
@@ -255,24 +255,17 @@
 ica.
-processing.Min
+GeoMat
 er
+i
 al;%0A
@@ -459,32 +459,40 @@
  static Map%3C
-OreMin
+IndustrialMat
 er
+i
 al,List%3CGeoM
@@ -501,24 +501,22 @@
 erial%3E%3E 
-oreMin
+mat
 er
+i
 alToGeoM
@@ -522,24 +522,28 @@
 Materials = 
+%0A%09%09%09
 new HashMap%3C
@@ -542,24 +542,32 @@
 HashMap%3C
-OreMin
+IndustrialMat
 er
+i
 al,List%3C
@@ -759,21 +759,32 @@
 al) %7B%0A%09%09
-Min
+IndustrialMat
 er
+i
 al conce
@@ -804,19 +804,16 @@
 rial.get
-Ore
 Concentr
@@ -841,82 +841,18 @@
 ate 
-instanceof OreMineral) %7B%0A%09%09%09OreMineral mineral = (OreMineral) concentrate;
+!= null) %7B
 %0A%09%09%09
@@ -881,24 +881,22 @@
 rials = 
-oreMiner
+materi
 alToGeoM
@@ -904,31 +904,35 @@
 terials.get(
-mineral
+concentrate
 );%0A%09%09%09if (ma
@@ -1000,24 +1000,22 @@
 ();%0A%09%09%09%09
-oreMin
+mat
 er
+i
 alToGeoM
@@ -1027,23 +1027,27 @@
 als.put(
-mineral
+concentrate
 , materi
@@ -1232,32 +1232,41 @@
 al%3E get(
-OreMin
+IndustrialMat
 er
+i
 al m
-in
+at
 er
+i
 al) %7B%0A%09%09
@@ -1276,16 +1276,14 @@
 urn 
-oreMin
+mat
 er
+i
 alTo
@@ -1300,20 +1300,21 @@
 ls.get(m
-in
+at
 er
+i
 al);%0A%09%7D%0A

generalize RawMaterial mapping beyond ores