* if the operation fails
*/
protected Collection<JClassType> getConnectorsForWidgetset(
TreeLogger logger, TypeOracle typeOracle)
throws UnableToCompleteException {
JClassType serverConnectorType;
try {
serverConnectorType = typeOracle.getType(ServerConnector.class
.getName());
} catch (NotFoundException e) {
logger.log(Type.ERROR,
"Can't find " + ServerConnector.class.getName());
throw new UnableToCompleteException();
}
JClassType[] types = serverConnectorType.getSubtypes();
Map<String, JClassType> mappings = new HashMap<String, JClassType>();
// Keep track of what has happened to avoid logging intermediate state
Map<JClassType, List<JClassType>> replaced = new HashMap<JClassType, List<JClassType>>();
for (JClassType type : types) {
Connect connectAnnotation = type.getAnnotation(Connect.class);
if (connectAnnotation == null) {
continue;
}
String identifier = connectAnnotation.value().getCanonicalName();
JClassType previousMapping = mappings.put(identifier, type);
if (previousMapping != null) {
// There are multiple mappings, pick the subclass
JClassType subclass;
JClassType superclass;
if (previousMapping.isAssignableFrom(type)) {
subclass = type;
superclass = previousMapping;
} else if (type.isAssignableFrom(previousMapping)) {
subclass = previousMapping;