if (!PROVIDE.equals(name)) return null;
if (!desc.startsWith("()")) return null;
if (factoryMethodFound) return null;
factoryMethodFound = true;
DescriptorImpl asAFactory = new DescriptorImpl();
generatedDescriptors.add(asAFactory);
asAFactory.setImplementation(implName);
asAFactory.setDescriptorType(DescriptorType.PROVIDE_METHOD);
String factoryType = desc.substring(2);
if (factoryType.charAt(0) == '[') {
// Array type, may not be of an object!
asAFactory.addAdvertisedContract(factoryType); // Just the array of whatever type
}
else {
if (factoryType.charAt(0) != 'L') {
throw new AssertionError("Unable to handle provide descriptor " + desc);
}
int endIndex = factoryType.indexOf(';');
if (endIndex < 0) {
throw new AssertionError("Unable to find end of class return type in descriptor " + desc);
}
String trueFactoryClass = factoryType.substring(1, endIndex);
// This might be parametererized, strip of the parameters
trueFactoryClass = trueFactoryClass.replace('/', '.');
Set<String> associatedContracts = utilities.getAssociatedContracts(
searchHere, trueFactoryClass);
for (String contract : associatedContracts) {
asAFactory.addAdvertisedContract(contract);
}
}
return new MethodVisitorImpl(asAFactory);
}