// Compute stack mappings from existing stack mappings
computedStackValues = computeStackMappings();
for (WrappedStack keyStack : computedStackValues.keySet())
{
EnergyValue factoredExchangeEnergyValue = null;
WrappedStack factoredKeyStack = null;
if (keyStack != null && keyStack.getWrappedStack() != null && keyStack.getStackSize() > 0)
{
if (computedStackValues.get(keyStack) != null && Float.compare(computedStackValues.get(keyStack).getEnergyValue(), 0f) > 0)
{
factoredExchangeEnergyValue = EnergyValueHelper.factorEnergyValue(computedStackValues.get(keyStack), keyStack.getStackSize());
factoredKeyStack = new WrappedStack(keyStack, 1);
}
}
if (factoredExchangeEnergyValue != null)
{
if (stackValueMap.containsKey(factoredKeyStack))
{
if (factoredExchangeEnergyValue.compareTo(stackValueMap.get(factoredKeyStack)) == -1)
{
stackValueMap.put(factoredKeyStack, factoredExchangeEnergyValue);
}
}
else
{
stackValueMap.put(factoredKeyStack, factoredExchangeEnergyValue);
}
}
}
}
/*
* Post-assigned values
*/
if (postAssignedMappings != null)
{
for (WrappedStack wrappedStack : postAssignedMappings.keySet())
{
stackValueMap.put(wrappedStack, postAssignedMappings.get(wrappedStack));
}
}
else
{
postAssignedMappings = new HashMap<WrappedStack, EnergyValue>();
}
// Grab custom post-assigned values from file
Map<WrappedStack, EnergyValue> postAssignedValueMap = SerializationHelper.readEnergyValueStackMapFromJsonFile(Files.POST_ASSIGNED_ENERGY_VALUES);
stackValueMap.putAll(postAssignedValueMap);
/**
* Finalize the stack to value map
*/
stackMappingsBuilder = ImmutableSortedMap.naturalOrder();
stackMappingsBuilder.putAll(stackValueMap);
stackMappings = stackMappingsBuilder.build();
/**
* Value map resolution
*/
SortedMap<EnergyValue, List<WrappedStack>> tempValueMappings = new TreeMap<EnergyValue, List<WrappedStack>>();
for (WrappedStack stack : stackMappings.keySet())
{
if (stack != null)
{
EnergyValue value = stackMappings.get(stack);
if (value != null)
{
if (tempValueMappings.containsKey(value))
{