package org.pfaa.chemica.registration;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import org.pfaa.chemica.model.Reaction;
import org.pfaa.chemica.processing.Stacking;
import org.pfaa.chemica.processing.Combination;
import org.pfaa.chemica.processing.EnthalpyChange;
import org.pfaa.chemica.processing.Separation;
import org.pfaa.chemica.processing.Sizing;

public class CombinedConversionRegistry implements ConversionRegistry {

	private Map<String,ConversionRegistry> registries = new HashMap<String,ConversionRegistry>();
	
	public void putRegistry(String key, ConversionRegistry registry) {
		registries.put(key, registry);
	}
	
	public ConversionRegistry getRegistry(String key) {
		return registries.get(key);
	}
	
	public Set<String> getRegistryNames() {
		return Collections.unmodifiableSet(registries.keySet());
	}

	@Override
	public void register(Stacking agglomeration) {
		for (ConversionRegistry registry : registries.values()) {
			registry.register(agglomeration);
		}
	}

	@Override
	public void register(Separation separation) {
		for (ConversionRegistry registry : registries.values()) {
			registry.register(separation);
		}
	}

	@Override
	public void register(Combination combination) {
		for (ConversionRegistry registry : registries.values()) {
			registry.register(combination);
		}
		
	}

	@Override
	public void register(Sizing sizing) {
		for (ConversionRegistry registry : registries.values()) {
			registry.register(sizing);
		}		
	}

	@Override
	public void register(EnthalpyChange enthalpyChange) {
		for (ConversionRegistry registry : registries.values()) {
			registry.register(enthalpyChange);
		}
	}

	@Override
	public void register(Reaction reaction) {
		for (ConversionRegistry registry : registries.values()) {
			registry.register(reaction);
		}		
	}
}

@@ -209,21 +209,21 @@
 cessing.
-Stack
+Alloy
 ing;%0Aimp
@@ -263,24 +263,119 @@
 ombination;%0A
+import org.pfaa.chemica.processing.Communition;%0Aimport org.pfaa.chemica.processing.Compaction;%0A
 import org.p
@@ -496,18 +496,65 @@
 essing.S
-iz
+melting;%0Aimport org.pfaa.chemica.processing.Stack
 ing;%0A%0Apu
@@ -1084,69 +1084,50 @@
 %7B%0A%09%09
-for (ConversionRegistry registry : registries.values()) %7B%0A%09%09%09
+registries.values().forEach((registry) -%3E 
 regi
@@ -1150,29 +1150,26 @@
 glomeration)
+)
 ;
-%0A%09%09%7D
 %0A%09%7D%0A%0A%09@Overr
@@ -1221,39 +1221,191 @@
 on) %7B%0A%09%09
-for (ConversionR
+registries.values().forEach((registry) -%3E registry.register(separation));%0A%09%7D%0A%0A%09@Override%0A%09public void register(Alloying alloying) %7B%0A%09%09registries.values().forEach((r
 egistry
+) -%3E
  registr
@@ -1409,37 +1409,122 @@
 stry
- : registries.values()) %7B%0A%09%09%09
+.register(alloying));%0A%09%7D%0A%09%0A%09public void register(Smelting smelting) %7B%0A%09%09registries.values().forEach((registry) -%3E 
 regi
@@ -1542,27 +1542,23 @@
 er(s
-eparation
+melting)
 );%0A
-%09
 %09%7D%0A%09
-%7D%0A
 %0A%09@O
@@ -1620,69 +1620,50 @@
 %7B%0A%09%09
-for (ConversionRegistry registry : registries.values()) %7B%0A%09%09%09
+registries.values().forEach((registry) -%3E 
 regi
@@ -1692,16 +1692,10 @@
 ion)
+)
 ;
-%0A%09%09%7D%0A%09%09
 %0A%09%7D%0A
@@ -1732,14 +1732,19 @@
 ter(
-Sizing
+Communition
  siz
@@ -1752,39 +1752,57 @@
 ng) %7B%0A%09%09
-for (ConversionR
+registries.values().forEach((r
 egistry
+) -%3E
  registr
@@ -1806,37 +1806,132 @@
 stry
- : registries.values()) %7B%0A%09%09%09
+.register(sizing));%09%09%0A%09%7D%0A%0A%09@Override%0A%09public void register(Compaction sizing) %7B%0A%09%09registries.values().forEach((registry) -%3E 
 regi
@@ -1951,21 +1951,18 @@
 (sizing)
+)
 ;
-%0A%09%09%7D
 %09%09%0A%09%7D%0A%0A%09
@@ -2032,69 +2032,50 @@
 %7B%0A%09%09
-for (ConversionRegistry registry : registries.values()) %7B%0A%09%09%09
+registries.values().forEach((registry) -%3E 
 regi
@@ -2103,21 +2103,18 @@
 yChange)
+)
 ;
-%0A%09%09%7D
 %0A%09%7D%0A%0A%09@O
@@ -2170,69 +2170,50 @@
 %7B%0A%09%09
-for (ConversionRegistry registry : registries.values()) %7B%0A%09%09%09
+registries.values().forEach((registry) -%3E 
 regi
@@ -2239,13 +2239,10 @@
 ion)
+)
 ;
-%0A%09%09%7D
 %09%09%0A%09

use Streams for looping over ConversionRegistries