public T find(String moduleId, String symbolId) throws IllegalArgumentException { if (moduleId != null) { SmiModule module = moduleMap.get(moduleId); if (module == null) { throw new IllegalArgumentException("Module " + moduleId + " could not be found."); } SmiSymbol symbol = module.findSymbol(symbolId); if (symbol == null) { return null; } if (symbolClass.isAssignableFrom(symbol.getClass())) { return symbolClass.cast(symbol); } else { // throw new // IllegalArgumentException(symbol.getClass().getSimpleName() + // " with id " + symbolId + " is not an instance of " + // m_symbolClass); return null; // when the lookup is through the global map, we // also return null for an object that is of the // wrong type. } } else { return getOne(symbolId); } }
public <T extends SmiSymbol> T resolveReference( IdToken idToken, Class<T> expectedClass, XRefProblemReporter reporter) { SmiSymbol result = resolveReference(idToken, reporter); if (result != null) { if (expectedClass.isInstance(result)) { return expectedClass.cast(result); } else { reporter.reportFoundSymbolButWrongType(idToken, expectedClass, result.getClass()); } } return null; }