/** * Given a type name, add all of the factories that respond to those types into the given table. * Each entry will be keyed by the adapter class name (supplied in * IAdapterFactory<IId>.getAdapterList). */ private void addFactoriesFor(DT adaptableType, Map<IId, IDynAdapterFactory<IId>> to) { List<IDynAdapterFactory<IId>> factoryList = factories.get(adaptableType); if (factoryList == null) return; for (IDynAdapterFactory<IId> factory : factoryList) { IId[] adapters = factory.getInterfaceIds(); for (IId a : adapters) { if (to.get(a) == null) { to.put(a, factory); } } } }
@Override public /*<T> T*/ Object getAdapter(Object adaptable, IId interfaceId) { DT adaptableType = dataTypeHierarchy.dataTypeOf(adaptable); IDynAdapterFactory<IId> factory = getFactories(adaptableType).get(interfaceId); /*T*/ Object result = null; if (factory != null) { result = factory.getAdapter(adaptable, interfaceId); } if (result == null && interfaceToLang.isInstance(adaptable, interfaceId)) { return /*(T)*/ adaptable; } return result; }