Any simple Java way to pass parts of a hashmap to another hashmap?

Posted by Arvanem on Stack Overflow See other posts from Stack Overflow or by Arvanem
Published on 2010-04-19T07:26:17Z Indexed on 2010/04/19 7:33 UTC
Read the original article Hit count: 318

Filed under:
|
|

Hi folks,

For my trading program, a Merchant object has a qualities HashMap of enumerated Qualities with Boolean values.

public class Merchants {
   private Map<Qualities, Boolean> qualities = new HashMap<Qualities, Boolean>();

I would like to give each Merchant object a further ratedQualities HashMap of True Qualities with Byte or Integer values representing the Rating of those Qualities.

For example, a given Merchant could have a "1" Rating associated with their True Stockbroking Quality.

The problem is Java does not let me do this easily. The following code demonstrates my intentions but doesn't compile:

private Map<qualities-TRUE, Byte> ratedQualities = new HashMap<qualities-TRUE, Byte>();

According to this link text one solution is to create a Wrapper for the qualities HashMap. Is this the only solution or is there a better way?

Thanks in advance for your help.

© Stack Overflow or respective owner

Related posts about java

Related posts about hashmap