class ProviderStack {

    public int addProvider(T provider) {
        if (provider == null) {
            throw new IllegalArgumentException("provider to add cannot be null");
        }
        int position = 0;
        refresh();
        int providerOrder = 0;
        if (provider instanceof NotProvider) {
            throw new IllegalArgumentException("Cannot place anything that implements NotProvider into the provider stack, failure for: " + provider);
        }
        if (provider instanceof OrderedService) {
            providerOrder = ((OrderedService)provider).getOrder();
        }
        // place at the bottom of the stack
        providers.add( new ProviderHolder<T>(provider) );
        if (providerOrder > 0) {
            // re-sort the providers
            Collections.sort(this.providers, new ProviderStackComparator());
        }
        return position;
    }

    public  ProviderStack();
    public  ProviderStack(ServiceManager serviceManager, Class<T> providerType);
    public  ProviderStack(T[] currentProviders);

}