DATAGEODE-302 - Refactor of(:TypeFilter) factory method to not double wrap a CompositeTypeFilter.
This commit is contained in:
@@ -161,7 +161,9 @@ public interface CompositeTypeFilter extends TypeFilter {
|
||||
|
||||
Assert.notNull(typeFilter, "TypeFilter to wrap must not be null");
|
||||
|
||||
return (metadataReader, metadataReaderFactory) -> typeFilter.match(metadataReader, metadataReaderFactory);
|
||||
return typeFilter instanceof CompositeTypeFilter
|
||||
? (CompositeTypeFilter) typeFilter
|
||||
: (metadataReader, metadataReaderFactory) -> typeFilter.match(metadataReader, metadataReaderFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -68,6 +68,14 @@ public class CompositeTypeFilterUnitTests {
|
||||
assertThat(CompositeTypeFilter.DENY.match(mockMetadataReader, mockMetadataReaderFactory)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ofWillNotWrapExistingCompositeTypeFilter() {
|
||||
|
||||
CompositeTypeFilter mockCompositeTypeFilter = mock(CompositeTypeFilter.class);
|
||||
|
||||
assertThat(CompositeTypeFilter.of(mockCompositeTypeFilter)).isSameAs(mockCompositeTypeFilter);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ofWrapsExistingTypeFilter() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user