@Test public void testFindFirstMatchingPathElement() { PathElement anchor = new PathElement(Type.INTERFACE_NAME, null, 1, 42); PathElement tailStart = new PathElement(Type.NODE_AND_INTERFACE_TAIL, null, 0, 42); PathElement nodeStart = new PathElement(Type.NODE_AND_INTERFACE, null, 0, 42); PathElement iname2 = new PathElement(Type.INTERFACE_NAME, null, 1, 42); PathElement tail2 = new PathElement(Type.NODE_AND_INTERFACE_TAIL, null, 0, 42); PotentialMatch pm = new PotentialMatch( anchor, "", ImmutableList.of(tail2, iname2, nodeStart, tailStart, anchor)); assertThat( ParboiledAutoComplete.findFirstMatchingPathElement(pm, 2, NODE_AND_INTERFACE_TAIL), equalTo(Optional.of(tailStart))); assertThat( ParboiledAutoComplete.findFirstMatchingPathElement(pm, 2, NODE_NAME), equalTo(Optional.empty())); assertThat( ParboiledAutoComplete.findFirstMatchingPathElement(pm, 2, INTERFACE_NAME), equalTo(Optional.of(iname2))); }
static Optional<PathElement> findFirstMatchingPathElement( PotentialMatch pm, int anchorIndex, Anchor.Type anchorType) { return IntStream.range(0, anchorIndex) .mapToObj(i -> pm.getPath().get(anchorIndex - i - 1)) .filter(pe -> pe.getAnchorType() == anchorType) .findFirst(); }
ParboiledAutoComplete { static Optional<PathElement> findFirstMatchingPathElement( PotentialMatch pm, int anchorIndex, Anchor.Type anchorType) { return IntStream.range(0, anchorIndex) .mapToObj(i -> pm.getPath().get(anchorIndex - i - 1)) .filter(pe -> pe.getAnchorType() == anchorType) .findFirst(); } }
ParboiledAutoComplete { static Optional<PathElement> findFirstMatchingPathElement( PotentialMatch pm, int anchorIndex, Anchor.Type anchorType) { return IntStream.range(0, anchorIndex) .mapToObj(i -> pm.getPath().get(anchorIndex - i - 1)) .filter(pe -> pe.getAnchorType() == anchorType) .findFirst(); } ParboiledAutoComplete(
      CommonParser parser,
      Grammar grammar,
      Map<String, Anchor.Type> completionTypes,
      String network,
      String snapshot,
      String query,
      int maxSuggestions,
      CompletionMetadata completionMetadata,
      NodeRolesData nodeRolesData,
      ReferenceLibrary referenceLibrary);   ParboiledAutoComplete(
      Grammar grammar,
      Rule inputRule,
      Map<String, Anchor.Type> completionTypes,
      String network,
      String snapshot,
      String query,
      int maxSuggestions,
      CompletionMetadata completionMetadata,
      NodeRolesData nodeRolesData,
      ReferenceLibrary referenceLibrary); }
ParboiledAutoComplete { static Optional<PathElement> findFirstMatchingPathElement( PotentialMatch pm, int anchorIndex, Anchor.Type anchorType) { return IntStream.range(0, anchorIndex) .mapToObj(i -> pm.getPath().get(anchorIndex - i - 1)) .filter(pe -> pe.getAnchorType() == anchorType) .findFirst(); } ParboiledAutoComplete(
      CommonParser parser,
      Grammar grammar,
      Map<String, Anchor.Type> completionTypes,
      String network,
      String snapshot,
      String query,
      int maxSuggestions,
      CompletionMetadata completionMetadata,
      NodeRolesData nodeRolesData,
      ReferenceLibrary referenceLibrary);   ParboiledAutoComplete(
      Grammar grammar,
      Rule inputRule,
      Map<String, Anchor.Type> completionTypes,
      String network,
      String snapshot,
      String query,
      int maxSuggestions,
      CompletionMetadata completionMetadata,
      NodeRolesData nodeRolesData,
      ReferenceLibrary referenceLibrary); static List<AutocompleteSuggestion> autoComplete(
      Grammar grammar,
      String network,
      String snapshot,
      String query,
      int maxSuggestions,
      CompletionMetadata completionMetadata,
      NodeRolesData nodeRolesData,
      ReferenceLibrary referenceLibrary); }
ParboiledAutoComplete { static Optional<PathElement> findFirstMatchingPathElement( PotentialMatch pm, int anchorIndex, Anchor.Type anchorType) { return IntStream.range(0, anchorIndex) .mapToObj(i -> pm.getPath().get(anchorIndex - i - 1)) .filter(pe -> pe.getAnchorType() == anchorType) .findFirst(); } ParboiledAutoComplete(
      CommonParser parser,
      Grammar grammar,
      Map<String, Anchor.Type> completionTypes,
      String network,
      String snapshot,
      String query,
      int maxSuggestions,
      CompletionMetadata completionMetadata,
      NodeRolesData nodeRolesData,
      ReferenceLibrary referenceLibrary);   ParboiledAutoComplete(
      Grammar grammar,
      Rule inputRule,
      Map<String, Anchor.Type> completionTypes,
      String network,
      String snapshot,
      String query,
      int maxSuggestions,
      CompletionMetadata completionMetadata,
      NodeRolesData nodeRolesData,
      ReferenceLibrary referenceLibrary); static List<AutocompleteSuggestion> autoComplete(
      Grammar grammar,
      String network,
      String snapshot,
      String query,
      int maxSuggestions,
      CompletionMetadata completionMetadata,
      NodeRolesData nodeRolesData,
      ReferenceLibrary referenceLibrary);  }