I am porting some PHP code over to Java. I have a class that defines the following map:
class Something {
protected $channels = array(
'a1' => array(
'path_key1' => 'provider_offices',
'path_key2' => 'provider_offices',
),
'a2' => array(
'path_key1' => 'provider_users',
'path_key2' => 'provider_users',
),
'a3' => array(
'path_key1' => 'provider_offices',
'path_key2' => 'provider_offices',
),
'a4' => array(
'path_key1' => 'attri1',
'path_key2' => 'attri1',
),
'a5' => array(
'path_key1' => 'attrib2',
'path_key2' => 'attrib2',
),
'a6' => array(
'path_key1' => 'diagnosis',
'path_key2' => 'diagnosis',
),
'a7' => array(
'path_key1' => 'meds',
'path_key2' => 'meds',
),
'a8' => array(
'path_key1' => 'risk1',
'path_key2' => 'risk1',
),
'a9' => array(
'path_key1' => 'risk2',
'path_key2' => 'risk2',
),
'a0' => array(
'path_key1' => 'visits',
'path_key2' => 'visits',
),
);
}
In PHP the data was being accessed by doing something like this:
$key = 'a9';
$pathKey2Value = $this->channels[$key]['path_key2'];
I started to implement a Map<String, Map<String, String>>
member in Java but it seemed overly complicated, as well as defining A1
, A2
, etc classes.
What would be the most elegant way to accomplish the same thing in Java?