CompositePattern implements RestrictionPattern { public static RestrictionPattern create(@NotNull List<RestrictionPattern> patterns) { switch (patterns.size()) { case 0 : return RestrictionPattern.EMPTY; case 1 : return patterns.get(0); default : return new CompositePattern(patterns); } } 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 testCreateFromEmptyList() { RestrictionPattern rp = CompositePattern.create(ImmutableList.<RestrictionPattern>of()); assertSame(RestrictionPattern.EMPTY, rp); }
@Test public void testCreateFromSingletonList() { RestrictionPattern rp = CompositePattern.create(ImmutableList.of(TestRestrictionPatter.INSTANCE_TRUE)); assertSame(TestRestrictionPatter.INSTANCE_TRUE, rp); }
@Test public void testCreateFromList() { RestrictionPattern rp = CompositePattern.create(ImmutableList.of(TestRestrictionPatter.INSTANCE_TRUE, TestRestrictionPatter.INSTANCE_FALSE)); assertTrue(rp instanceof CompositePattern); }