diff --git a/src/main/java/spoon/reflect/visitor/Filter.java b/src/main/java/spoon/reflect/visitor/Filter.java index b1aef0ed2d4..8479169d8e4 100644 --- a/src/main/java/spoon/reflect/visitor/Filter.java +++ b/src/main/java/spoon/reflect/visitor/Filter.java @@ -16,8 +16,6 @@ */ package spoon.reflect.visitor; -import java.util.function.Predicate; - import spoon.reflect.declaration.CtElement; /** @@ -27,15 +25,10 @@ * the type of the filtered elements (an element belonging to the * filtered element must be assignable from T). */ -public interface Filter extends Predicate { +public interface Filter { /** * Tells if the given element matches. * @param element - the element to be checked for a match. Parameter element is never null if {@link Query} is used. */ boolean matches(T element); - - @Override - default boolean test(T element) { - return matches(element); - } } diff --git a/src/main/java/spoon/reflect/visitor/filter/AbstractFilter.java b/src/main/java/spoon/reflect/visitor/filter/AbstractFilter.java index 4d434982f84..19b56b5cddd 100644 --- a/src/main/java/spoon/reflect/visitor/filter/AbstractFilter.java +++ b/src/main/java/spoon/reflect/visitor/filter/AbstractFilter.java @@ -60,9 +60,4 @@ public Class getType() { public boolean matches(T element) { return type.isAssignableFrom(element.getClass()); } - - @Override - public boolean test(T element) { - return matches(element); - } } diff --git a/src/test/java/spoon/test/filters/FilterTest.java b/src/test/java/spoon/test/filters/FilterTest.java index 1cdedd6e631..de6d05474fe 100644 --- a/src/test/java/spoon/test/filters/FilterTest.java +++ b/src/test/java/spoon/test/filters/FilterTest.java @@ -1285,13 +1285,4 @@ public void testNameFilterWithGenericType() { assertEquals(1, ctFields.size()); assertTrue(ctFields.get(0) instanceof CtField); } - - @Test - public void testFilterAsPredicate() throws Exception { - CtClass foo = factory.Package().get("spoon.test.filters").getType("Foo"); - //contract: Spoon Filter is compatible with java.util.function.Predicate - Predicate predicate = new NamedElementFilter<>(CtClass.class, "Foo"); - assertTrue(predicate.test(foo)); - assertFalse(predicate.test(foo.getTypeMembers().get(0))); - } }