public Map<String, Map<String, JsonNode>> computeDisplayValues(DisplayHints displayHints) { _displayValues = new HashMap<>(); // reset anything we may have done in the past for (Entry<String, Extraction> entry : displayHints.getExtractions().entrySet()) { JsonPathExtractionHint jpeHint = null; try { jpeHint = JsonPathExtractionHint.fromExtractionHint(entry.getValue()); } catch (IOException e) { throw new BatfishException( "Could not extract JsonPathExtractionHint from ExtractionHint", e); } switch (jpeHint.getUse()) { case PREFIX: extractValuesFromPrefix(entry.getKey(), entry.getValue(), jpeHint); break; case FUNCOFSUFFIX: case PREFIXOFSUFFIX: case SUFFIXOFSUFFIX: extractValuesFromSuffix(entry.getKey(), entry.getValue(), jpeHint); break; default: throw new BatfishException("Unknown use type " + jpeHint.getUse()); } } if (displayHints.getCompositions() != null) { doCompositions(displayHints.getCompositions(), displayHints.getExtractions()); } return _displayValues; }
private DisplayHints getComposition(String displayVariable) { DisplayHints displayHints = new DisplayHints(); Map<String, Composition> compositions = new HashMap<>(); Composition composition = _displayHints.getCompositions().get(displayVariable); compositions.put(displayVariable, composition); displayHints.setCompositions(compositions); Map<String, Extraction> extractions = new HashMap<>(); for (String varName : composition.getDictionary().values()) { extractions.put(varName, _displayHints.getExtractions().get(varName)); } displayHints.setExtractions(extractions); return displayHints; }