I have kind of a really strange problem. I have a simple Map called vectors where I store StrategyPairs as keys and Vectors as the values. When I print it, I get this result:
{net.softwarepage.facharbeit.normalgame.logic.StrategyPair@131e56d7=(1.0;2.0), net.softwarepage.facharbeit.normalgame.logic.StrategyPair@1e1bc985=(2.0;2.0), net.softwarepage.facharbeit.normalgame.logic.StrategyPair@d5415975=(0.0;2.0), net.softwarepage.facharbeit.normalgame.logic.StrategyPair@5bf8c6e7=(2.0;1.0)}
As you can see StrategyPair@131e56d7
is mapped to a Vector (1,2).
Now I create a new StrategyPair. When I print it I get StrategyPair@131e56d7
(the same one as before).
However, if I now call vectors.get(strategyPair)
it returns null.
This is somehow really strange as the key is the same (at least it prints the exact same thing out when I print it...)
The problem arises when I rename a strategy, e.g. I change the property name in the class "Strategy". Then suddenly the map which contains StrategyPairs (a wrapper class for two strategies) is messed up as I explained before...
EDIT: When I print the HashMap I still get the same result as above, but the following code:
for(StrategyPair pair : vectors.keySet()) {
System.out.println(vectors.get(pair));
}
returns: null (2.0;2.0) null (2.0;1.0)