@Test public void testRefresh() { Provider p1 = new OrderedProvider("aaa", 2); Provider p2 = new UnorderedProvider("ccc"); ProviderStack<Provider> providers = new ProviderStack<Provider>(new Provider[] { p2, new UnorderedProvider("ddd"), new OrderedProvider("bbb", 5), p1 }); assertNotNull(providers.hashCode()); assertNotNull(providers.toString()); assertEquals(4, providers.size()); providers.refresh(); assertEquals(4, providers.size()); System.gc(); providers.refresh(); assertEquals(2, providers.size()); assertEquals(p1, providers.getProvider(0)); assertEquals(p2, providers.getProvider(1)); p1 = null; System.gc(); providers.refresh(); assertEquals(1, providers.size()); assertEquals(p2, providers.getProvider(0)); p2 = null; providers.clear(); providers = null; }
protected List<T> refresh() { ArrayList<T> l = new ArrayList<T>(); for (Iterator<ProviderHolder<T>> iterator = providers.iterator(); iterator.hasNext(); ) { ProviderHolder<T> holder = iterator.next(); T provider = holder.getProvider(); if (provider == null) { iterator.remove(); } else { l.add(provider); } } return l; }
ProviderStack { protected List<T> refresh() { ArrayList<T> l = new ArrayList<T>(); for (Iterator<ProviderHolder<T>> iterator = providers.iterator(); iterator.hasNext(); ) { ProviderHolder<T> holder = iterator.next(); T provider = holder.getProvider(); if (provider == null) { iterator.remove(); } else { l.add(provider); } } return l; } }
ProviderStack { protected List<T> refresh() { ArrayList<T> l = new ArrayList<T>(); for (Iterator<ProviderHolder<T>> iterator = providers.iterator(); iterator.hasNext(); ) { ProviderHolder<T> holder = iterator.next(); T provider = holder.getProvider(); if (provider == null) { iterator.remove(); } else { l.add(provider); } } return l; } ProviderStack();  ProviderStack(ServiceManager serviceManager, Class<T> providerType);  ProviderStack(T[] currentProviders); }
ProviderStack { protected List<T> refresh() { ArrayList<T> l = new ArrayList<T>(); for (Iterator<ProviderHolder<T>> iterator = providers.iterator(); iterator.hasNext(); ) { ProviderHolder<T> holder = iterator.next(); T provider = holder.getProvider(); if (provider == null) { iterator.remove(); } else { l.add(provider); } } return l; } ProviderStack();  ProviderStack(ServiceManager serviceManager, Class<T> providerType);  ProviderStack(T[] currentProviders); int addProvider(T provider); boolean removeProvider(final int position); boolean removeProvider(T provider); List<T> getProviders(); List<ProviderHolder<T>> getProviderHolders(); Iterator<T> getIterator(); T getProvider(final int position); ProviderHolder<T> getProviderHolder(final int position); int size(); void clear(); }
ProviderStack { protected List<T> refresh() { ArrayList<T> l = new ArrayList<T>(); for (Iterator<ProviderHolder<T>> iterator = providers.iterator(); iterator.hasNext(); ) { ProviderHolder<T> holder = iterator.next(); T provider = holder.getProvider(); if (provider == null) { iterator.remove(); } else { l.add(provider); } } return l; } ProviderStack();  ProviderStack(ServiceManager serviceManager, Class<T> providerType);  ProviderStack(T[] currentProviders); int addProvider(T provider); boolean removeProvider(final int position); boolean removeProvider(T provider); List<T> getProviders(); List<ProviderHolder<T>> getProviderHolders(); Iterator<T> getIterator(); T getProvider(final int position); ProviderHolder<T> getProviderHolder(final int position); int size(); void clear();  }