CompositePattern implements RestrictionPattern { @Override public boolean matches(@NotNull Tree tree, @Nullable PropertyState property) { for (RestrictionPattern pattern : patterns) { if (!pattern.matches(tree, property)) { return false; } } return true; } CompositePattern(@NotNull List<RestrictionPattern> patterns); static RestrictionPattern create(@NotNull List<RestrictionPattern> patterns); @Override boolean matches(@NotNull Tree tree, @Nullable PropertyState property); @Override boolean matches(@NotNull String path); @Override boolean matches();  }
@Test public void testMatches() { assertTrue(alwaysMatching.matches()); assertFalse(neverMatching.matches()); }
@Test public void testMatchesPath() { List<String> paths = ImmutableList.of("/", "/a", "/a/b/c", ""); for (String path : paths) { assertTrue(alwaysMatching.matches(path)); assertFalse(neverMatching.matches(path)); } }
@Test public void testMatchesTree() { Tree tree = Mockito.mock(Tree.class); assertTrue(alwaysMatching.matches(tree, null)); assertFalse(neverMatching.matches(tree, null)); }
@Test public void testMatchesTreeProperty() { Tree tree = Mockito.mock(Tree.class); PropertyState property = PropertyStates.createProperty("prop", "value"); assertTrue(alwaysMatching.matches(tree, property)); assertFalse(neverMatching.matches(tree, property)); }