@Test public void testCreateKnownAnchor() { Element element = new Element(new MockMatcher("label"), 1, 2); assertThat( PathElement.create(element, ImmutableMap.of("label", ADDRESS_GROUP_NAME)), equalTo(new PathElement(ADDRESS_GROUP_NAME, "label", 2, 1))); }
static PathElement create(Element element, Map<String, Type> anchorTypes) { String label = element.matcher.getLabel(); Anchor.Type anchorType = anchorTypes.containsKey(label) ? anchorTypes.get(label) : isStringLiteralLabel(label) ? STRING_LITERAL : isCharLiteralLabel(label) ? CHAR_LITERAL : null; return new PathElement(anchorType, label, element.level, element.startIndex); }
PathElement { static PathElement create(Element element, Map<String, Type> anchorTypes) { String label = element.matcher.getLabel(); Anchor.Type anchorType = anchorTypes.containsKey(label) ? anchorTypes.get(label) : isStringLiteralLabel(label) ? STRING_LITERAL : isCharLiteralLabel(label) ? CHAR_LITERAL : null; return new PathElement(anchorType, label, element.level, element.startIndex); } }
PathElement { static PathElement create(Element element, Map<String, Type> anchorTypes) { String label = element.matcher.getLabel(); Anchor.Type anchorType = anchorTypes.containsKey(label) ? anchorTypes.get(label) : isStringLiteralLabel(label) ? STRING_LITERAL : isCharLiteralLabel(label) ? CHAR_LITERAL : null; return new PathElement(anchorType, label, element.level, element.startIndex); } PathElement(@Nullable Anchor.Type anchorType, String label, int level, int startIndex); }
PathElement { static PathElement create(Element element, Map<String, Type> anchorTypes) { String label = element.matcher.getLabel(); Anchor.Type anchorType = anchorTypes.containsKey(label) ? anchorTypes.get(label) : isStringLiteralLabel(label) ? STRING_LITERAL : isCharLiteralLabel(label) ? CHAR_LITERAL : null; return new PathElement(anchorType, label, element.level, element.startIndex); } PathElement(@Nullable Anchor.Type anchorType, String label, int level, int startIndex); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
PathElement { static PathElement create(Element element, Map<String, Type> anchorTypes) { String label = element.matcher.getLabel(); Anchor.Type anchorType = anchorTypes.containsKey(label) ? anchorTypes.get(label) : isStringLiteralLabel(label) ? STRING_LITERAL : isCharLiteralLabel(label) ? CHAR_LITERAL : null; return new PathElement(anchorType, label, element.level, element.startIndex); } PathElement(@Nullable Anchor.Type anchorType, String label, int level, int startIndex); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }