What is the proper Java type to use for a lookup table of constants that have a one-to-one relationship with other constants? For instance:
A1 <-> B1
A2 <-> B2
A3 <-> B3
where all As and Bs are known at compile time. I need to be able to call something like this in the code:
B = getB(A)
My initial thoughts were a Map or Enum.
If you just want the mapping to go one way (i.e. lookup B for A), then a
java.util.Mapimplementation will do fine.If you want the mapping to go both ways (i.e. lookup B for A and lookup A for B), then either use two
java.util.Mapinstances or a bidirectional map interface; e.g. the Guava BiMap interface.