For example, in a Spring config I have a map like this-
<util:map id="someMap"
map-class="java.util.HashMap"
key-type="java.lang.String"
value-type="java.lang.String" >
<entry key="A" value="Apple" />
<entry key="B" value="Banana" />
<entry key="C" value="Cherry" />
<entry key="D" value="Durian" />
<entry key="Default" value="None" />
Now, I have a method-
private String getFruitName(){
/* result should come from config depending on the
value of this.fruit [a fruit type which can be one
of the first four keys in the map.] */
}
How do I do that directly with condition set to spring config file rather than getting the value by injecting the key from my method in the class? Can I use conditional statements in the config and maybe pass a parameter to the config?
I don't want to do something like -
if (someMap.containsKey(fruit)){
fruitName = someMap.get(fruit);
}