EvaluatorUtil { static public Map<String, ?> decodeAll(Map<FieldName, ?> map){ Map<String, Object> result = new LinkedHashMap<>(2 * map.size()); Collection<? extends Map.Entry<FieldName, ?>> entries = map.entrySet(); for(Map.Entry<FieldName, ?> entry : entries){ FieldName name = entry.getKey(); Object value = entry.getValue(); try { value = decode(value); } catch(UnsupportedOperationException uoe){ continue; } result.put(name != null ? name.getValue() : null, value); } return result; } private  EvaluatorUtil(); static Map<FieldName, ?> encodeKeys(Map<String, ?> map); static Object decode(Object object); static Map<String, ?> decodeAll(Map<FieldName, ?> map); static List<? extends Map<FieldName, ?>> groupRows(HasGroupFields hasGroupFields, List<? extends Map<FieldName, ?>> table); static List<Map<K, Object>> groupRows(K groupKey, List<? extends Map<K, ?>> table);  }
@Test public void decodeAll(){ Computable value = new Computable(){ @Override public String getResult(){ return "value"; } }; assertEquals(Collections.singletonMap((String)null, "value"), EvaluatorUtil.decodeAll(Collections.singletonMap((FieldName)null, value))); assertEquals(Collections.singletonMap("key", "value"), EvaluatorUtil.decodeAll(Collections.singletonMap(FieldName.create("key"), value))); Computable invalidValue = new Computable(){ @Override public Object getResult(){ throw new UnsupportedOperationException(); } }; assertEquals(Collections.emptyMap(), EvaluatorUtil.decodeAll(Collections.singletonMap((FieldName)null, invalidValue))); assertEquals(Collections.emptyMap(), EvaluatorUtil.decodeAll(Collections.singletonMap(FieldName.create("key"), invalidValue))); Map<FieldName, Object> results = new LinkedHashMap<>(); results.put((FieldName)null, invalidValue); results.put(FieldName.create("decision"), Boolean.TRUE); assertEquals(Collections.singletonMap("decision", Boolean.TRUE), EvaluatorUtil.decodeAll(results)); }