private List<PropertyDescriptor> getAdapterPropertyDescriptors0(Class<?> type) { if (type == null) { throw new IllegalArgumentException("Type must be non-null"); } loadProvidersIfNecessary(); ArrayList<PropertyDescriptor> des = new ArrayList<PropertyDescriptor>(); for (BeanAdapterProvider provider : providers) { Class<?> pdType = provider.getAdapterClass(type); if (pdType != null) { BeanInfo info = getBeanInfo(pdType); if (info != null) { PropertyDescriptor[] pds = info.getPropertyDescriptors(); if (pds != null) { for (PropertyDescriptor pd : pds) { if (provider.providesAdapter(type, pd.getName())) { des.add(pd); } } } } } } return des; }
private BeanAdapterProvider getProvider(Object source, String property) { Class<?> type = source.getClass(); for (BeanAdapterProvider provider : providers) { if (provider.providesAdapter(type, property)) { return provider; } } return null; }
public Object getAdapter0(Object source, String property) { if ((source == null) || (property == null)) { throw new IllegalArgumentException(); } loadProvidersIfNecessary(); property = property.intern(); BeanAdapterProvider provider = getProvider(source, property); if (provider != null) { List<VendedAdapter> adapters = vendedAdapters.get(source); if (adapters != null) { for (int i = adapters.size() - 1; i >= 0; i--) { VendedAdapter vendedAdapter = adapters.get(i); Object adapter = vendedAdapter.getAdapter(); if (adapter == null) { vendedAdapters.remove(i); } else if ((vendedAdapter.getProvider() == provider) && (vendedAdapter.getProperty() == property)) { return adapter; } } } else { adapters = new ArrayList<VendedAdapter>(1); vendedAdapters.put(source, adapters); } Object adapter = provider.createAdapter(source, property); adapters.add(new VendedAdapter(property, provider, adapter)); return adapter; } return null; }