@Test public void decode(){ assertEquals(null, EvaluatorUtil.decode((Object)null)); Computable value = new Computable(){ @Override public String getResult(){ return "value"; } }; assertEquals("value", EvaluatorUtil.decode(value)); assertEquals(Arrays.asList("value"), EvaluatorUtil.decode(Arrays.asList(value))); assertEquals(Arrays.asList("value", "value"), EvaluatorUtil.decode(Arrays.asList(value, value))); Computable invalidValue = new Computable(){ @Override public Object getResult(){ throw new UnsupportedOperationException(); } }; try { EvaluatorUtil.decode(invalidValue); fail(); } catch(UnsupportedOperationException uoe){ } }
static public Object decode(Object object){ if(object instanceof Computable){ Computable computable = (Computable)object; return computable.getResult(); } if(object instanceof Collection){ Collection<?> rawValues = (Collection<?>)object; Collection<Object> decodedValues; if(rawValues instanceof Set){ decodedValues = new LinkedHashSet<>(rawValues.size()); } else { decodedValues = new ArrayList<>(rawValues.size()); } for(Object rawValue : rawValues){ decodedValues.add(decode(rawValue)); } return decodedValues; } return object; }
EvaluatorUtil { static public Object decode(Object object){ if(object instanceof Computable){ Computable computable = (Computable)object; return computable.getResult(); } if(object instanceof Collection){ Collection<?> rawValues = (Collection<?>)object; Collection<Object> decodedValues; if(rawValues instanceof Set){ decodedValues = new LinkedHashSet<>(rawValues.size()); } else { decodedValues = new ArrayList<>(rawValues.size()); } for(Object rawValue : rawValues){ decodedValues.add(decode(rawValue)); } return decodedValues; } return object; } }
EvaluatorUtil { static public Object decode(Object object){ if(object instanceof Computable){ Computable computable = (Computable)object; return computable.getResult(); } if(object instanceof Collection){ Collection<?> rawValues = (Collection<?>)object; Collection<Object> decodedValues; if(rawValues instanceof Set){ decodedValues = new LinkedHashSet<>(rawValues.size()); } else { decodedValues = new ArrayList<>(rawValues.size()); } for(Object rawValue : rawValues){ decodedValues.add(decode(rawValue)); } return decodedValues; } return object; } private  EvaluatorUtil(); }
EvaluatorUtil { static public Object decode(Object object){ if(object instanceof Computable){ Computable computable = (Computable)object; return computable.getResult(); } if(object instanceof Collection){ Collection<?> rawValues = (Collection<?>)object; Collection<Object> decodedValues; if(rawValues instanceof Set){ decodedValues = new LinkedHashSet<>(rawValues.size()); } else { decodedValues = new ArrayList<>(rawValues.size()); } for(Object rawValue : rawValues){ decodedValues.add(decode(rawValue)); } return decodedValues; } return object; } 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); }
EvaluatorUtil { static public Object decode(Object object){ if(object instanceof Computable){ Computable computable = (Computable)object; return computable.getResult(); } if(object instanceof Collection){ Collection<?> rawValues = (Collection<?>)object; Collection<Object> decodedValues; if(rawValues instanceof Set){ decodedValues = new LinkedHashSet<>(rawValues.size()); } else { decodedValues = new ArrayList<>(rawValues.size()); } for(Object rawValue : rawValues){ decodedValues.add(decode(rawValue)); } return decodedValues; } return object; } 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);  }