| 35 | |
| 36 | |
| 37 | public class MapModelAdaptor implements ModelAdaptor { |
| 38 | @Override |
| 39 | public Object getProperty(Interpreter interp, ST self, Object o, Object property, String propertyName) throws STNoSuchPropertyException { |
| 40 | Object value; |
| 41 | Map<?, ?> map = (Map<?, ?>)o; |
| 42 | if ( property==null ) value = map.get(STGroup.DEFAULT_KEY); |
| 43 | else if ( property.equals("keys") ) value = map.keySet(); |
| 44 | else if ( property.equals("values") ) value = map.values(); |
| 45 | else if ( map.containsKey(property) ) value = map.get(property); |
| 46 | else if ( map.containsKey(propertyName) ) { // if can't find the key, try toString version |
| 47 | value = map.get(propertyName); |
| 48 | } |
| 49 | else value = map.get(STGroup.DEFAULT_KEY); // not found, use default |
| 50 | if ( value==STGroup.DICT_KEY ) { |
| 51 | value = property; |
| 52 | } |
| 53 | return value; |
| 54 | } |
| 55 | } |
nothing calls this directly
no outgoing calls
no test coverage detected