@Test public void testNoMatchRecursive() throws Exception { when(typeDescription.getSuperClass()).thenReturn(superType); when(superType.getSuperClass()).thenReturn(superType); assertThat(new HasSuperTypeMatcher<TypeDescription>(typeMatcher).matches(typeDescription), is(false)); }
public boolean matches(T target) { Set<TypeDescription> previous = new HashSet<TypeDescription>(); for (TypeDefinition typeDefinition : target) { if (!previous.add(typeDefinition.asErasure())) { return false; } else if (matcher.matches(typeDefinition.asGenericType())) { return true; } LinkedList<TypeDefinition> interfaceTypes = new LinkedList<TypeDefinition>(typeDefinition.getInterfaces()); while (!interfaceTypes.isEmpty()) { TypeDefinition interfaceType = interfaceTypes.removeFirst(); if (previous.add(interfaceType.asErasure())) { if (matcher.matches(interfaceType.asGenericType())) { return true; } else { interfaceTypes.addAll(interfaceType.getInterfaces()); } } } } return false; }
HasSuperTypeMatcher extends ElementMatcher.Junction.AbstractBase<T> { public boolean matches(T target) { Set<TypeDescription> previous = new HashSet<TypeDescription>(); for (TypeDefinition typeDefinition : target) { if (!previous.add(typeDefinition.asErasure())) { return false; } else if (matcher.matches(typeDefinition.asGenericType())) { return true; } LinkedList<TypeDefinition> interfaceTypes = new LinkedList<TypeDefinition>(typeDefinition.getInterfaces()); while (!interfaceTypes.isEmpty()) { TypeDefinition interfaceType = interfaceTypes.removeFirst(); if (previous.add(interfaceType.asErasure())) { if (matcher.matches(interfaceType.asGenericType())) { return true; } else { interfaceTypes.addAll(interfaceType.getInterfaces()); } } } } return false; } }
HasSuperTypeMatcher extends ElementMatcher.Junction.AbstractBase<T> { public boolean matches(T target) { Set<TypeDescription> previous = new HashSet<TypeDescription>(); for (TypeDefinition typeDefinition : target) { if (!previous.add(typeDefinition.asErasure())) { return false; } else if (matcher.matches(typeDefinition.asGenericType())) { return true; } LinkedList<TypeDefinition> interfaceTypes = new LinkedList<TypeDefinition>(typeDefinition.getInterfaces()); while (!interfaceTypes.isEmpty()) { TypeDefinition interfaceType = interfaceTypes.removeFirst(); if (previous.add(interfaceType.asErasure())) { if (matcher.matches(interfaceType.asGenericType())) { return true; } else { interfaceTypes.addAll(interfaceType.getInterfaces()); } } } } return false; } HasSuperTypeMatcher(ElementMatcher<? super TypeDescription.Generic> matcher); }
HasSuperTypeMatcher extends ElementMatcher.Junction.AbstractBase<T> { public boolean matches(T target) { Set<TypeDescription> previous = new HashSet<TypeDescription>(); for (TypeDefinition typeDefinition : target) { if (!previous.add(typeDefinition.asErasure())) { return false; } else if (matcher.matches(typeDefinition.asGenericType())) { return true; } LinkedList<TypeDefinition> interfaceTypes = new LinkedList<TypeDefinition>(typeDefinition.getInterfaces()); while (!interfaceTypes.isEmpty()) { TypeDefinition interfaceType = interfaceTypes.removeFirst(); if (previous.add(interfaceType.asErasure())) { if (matcher.matches(interfaceType.asGenericType())) { return true; } else { interfaceTypes.addAll(interfaceType.getInterfaces()); } } } } return false; } HasSuperTypeMatcher(ElementMatcher<? super TypeDescription.Generic> matcher); boolean matches(T target); @Override String toString(); }
HasSuperTypeMatcher extends ElementMatcher.Junction.AbstractBase<T> { public boolean matches(T target) { Set<TypeDescription> previous = new HashSet<TypeDescription>(); for (TypeDefinition typeDefinition : target) { if (!previous.add(typeDefinition.asErasure())) { return false; } else if (matcher.matches(typeDefinition.asGenericType())) { return true; } LinkedList<TypeDefinition> interfaceTypes = new LinkedList<TypeDefinition>(typeDefinition.getInterfaces()); while (!interfaceTypes.isEmpty()) { TypeDefinition interfaceType = interfaceTypes.removeFirst(); if (previous.add(interfaceType.asErasure())) { if (matcher.matches(interfaceType.asGenericType())) { return true; } else { interfaceTypes.addAll(interfaceType.getInterfaces()); } } } } return false; } HasSuperTypeMatcher(ElementMatcher<? super TypeDescription.Generic> matcher); boolean matches(T target); @Override String toString();  }