@Override public MetaClass getEnclosingType(final HasAnnotations annotated) { return ((MetaParameter) annotated).getDeclaringMember().getDeclaringClass(); }
private void resolveProducerSpecialization(final InjectableImpl specialization, final Set<InjectableImpl> toBeRemoved) { final ProducerInstanceDependencyImpl producerMemberDep = GraphUtil.findProducerInstanceDep(specialization); if (producerMemberDep.producingMember instanceof MetaMethod) { final MetaMethod specializedMethod = GraphUtil.getOverridenMethod((MetaMethod) producerMemberDep.producingMember); final MetaClass specializingType = producerMemberDep.producingMember.getDeclaringClass(); if (specializedMethod != null && specializedMethod.isAnnotationPresent(Produces.class)) { updateLinksToSpecialized(specialization, toBeRemoved, specializedMethod, specializingType); } } else { throw new RuntimeException("Specialized producers can only be methods. Found " + producerMemberDep.producingMember + " in " + producerMemberDep.producingMember.getDeclaringClassName()); } }
private static void filterResultsParameter(final Collection<MetaParameter> result, final Set<String> packages, final String excludeRegEx) { final Pattern excludePattern; if (excludeRegEx != null) { excludePattern = Pattern.compile(excludeRegEx); } else { excludePattern = null; } final Iterator<MetaParameter> filterIterator = result.iterator(); while (filterIterator.hasNext()) { _removeIfNotMatches(filterIterator, filterIterator.next().getDeclaringMember().getDeclaringClass(), packages, excludePattern); } }
private static void filterResultsParameter(final Collection<MetaParameter> result, final Set<String> packages, final String excludeRegEx) { final Pattern excludePattern; if (excludeRegEx != null) { excludePattern = Pattern.compile(excludeRegEx); } else { excludePattern = null; } final Iterator<MetaParameter> filterIterator = result.iterator(); while (filterIterator.hasNext()) { _removeIfNotMatches(filterIterator, filterIterator.next().getDeclaringMember().getDeclaringClass(), packages, excludePattern); } }
private int getScore(final InjectableImpl c) { if (c.injectableType.equals(InjectableType.Producer)) { return getDistanceFromObject(findProducerInstanceDep(c).producingMember.getDeclaringClass()); } else { return getDistanceFromObject(c.type); } }
private void removeLinksToProducedTypes(final InjectableImpl specialized, final Set<InjectableImpl> toBeRemoved) { final Collection<InjectableReference> producedReferences = new ArrayList<>(); for (final MetaMethod method : specialized.type.getDeclaredMethodsAnnotatedWith(Produces.class)) { producedReferences.add(lookupInjectableReference(method.getReturnType(), qualFactory.forSource(method))); } for (final MetaField field : specialized.type.getDeclaredFields()) { if (field.isAnnotationPresent(Produces.class)) { producedReferences.add(lookupInjectableReference(field.getType(), qualFactory.forSource(field))); } } for (final InjectableReference reference : producedReferences) { final Iterator<InjectableBase> linkIter = reference.linked.iterator(); while (linkIter.hasNext()) { final InjectableBase link = linkIter.next(); if (link instanceof InjectableImpl && ((InjectableImpl) link).injectableType.equals(InjectableType.Producer)) { final InjectableImpl concreteLink = (InjectableImpl) link; final ProducerInstanceDependencyImpl producerMemberDep = GraphUtil.findProducerInstanceDep(concreteLink); if (producerMemberDep.producingMember.getDeclaringClass().equals(specialized.type)) { linkIter.remove(); toBeRemoved.add(concreteLink); } } } } }