/** * Creates a new {@link ProvisionListenerStackCallback} with the correct listeners for the key. */ private <T> ProvisionListenerStackCallback<T> create(Binding<T> binding) { List<ProvisionListener> listeners = null; for (ProvisionListenerBinding provisionBinding : listenerBindings) { if (provisionBinding.getBindingMatcher().matches(binding)) { if (listeners == null) { listeners = Lists.newArrayList(); } listeners.addAll(provisionBinding.getListeners()); } } if (listeners == null || listeners.isEmpty()) { // Optimization: don't bother constructing the callback if there are // no listeners. return ProvisionListenerStackCallback.emptyListener(); } return new ProvisionListenerStackCallback<T>(binding, listeners); }
/** * Creates a new {@link ProvisionListenerStackCallback} with the correct listeners * for the key. */ private <T> ProvisionListenerStackCallback<T> create(Binding<T> binding) { List<ProvisionListener> listeners = null; for (ProvisionListenerBinding provisionBinding : listenerBindings) { if (provisionBinding.getBindingMatcher().matches(binding)) { if (listeners == null) { listeners = Lists.newArrayList(); } listeners.addAll(provisionBinding.getListeners()); } } if (listeners == null || listeners.isEmpty()) { // Optimization: don't bother constructing the callback if there are // no listeners. return ProvisionListenerStackCallback.emptyListener(); } return new ProvisionListenerStackCallback<T>(binding, listeners); }
@Override public List<ProvisionListenerBinding> getProvisionListenerBindings() { List<ProvisionListenerBinding> parentBindings = parent.getProvisionListenerBindings(); List<ProvisionListenerBinding> result = Lists.newArrayListWithCapacity(parentBindings.size() + provisionListenerBindings.size()); result.addAll(parentBindings); result.addAll(provisionListenerBindings); return result; }
public List<ProvisionListenerBinding> getProvisionListenerBindings() { List<ProvisionListenerBinding> parentBindings = parent.getProvisionListenerBindings(); List<ProvisionListenerBinding> result = new ArrayList<ProvisionListenerBinding>(parentBindings.size() + 1); result.addAll(parentBindings); result.addAll(provisionListenerBindings); return result; }
@Override public V visit(ProvisionListenerBinding binding) { return message(binding, "Binding provision listeners " + binding.getListeners() + " for bindings matching " + binding.getBindingMatcher()); }
@Override public void addProvisionListener(ProvisionListenerBinding listenerBinding) { provisionListenerBindings.add(listenerBinding); }
@Override public Boolean visit(ProvisionListenerBinding binding) { injector.state.addProvisionListener(binding); return true; }
@Override public void addProvisionListener(ProvisionListenerBinding provisionListenerBinding) { throw new UnsupportedOperationException(); }
@Override public List<ProvisionListenerBinding> getProvisionListenerBindings() { return ImmutableList.of(); }
ProvisionListenerCallbackStore(List<ProvisionListenerBinding> listenerBindings) { this.listenerBindings = ImmutableList.copyOf(listenerBindings); }
public void addProvisionListener(ProvisionListenerBinding listenerBinding) { provisionListenerBindings.add(listenerBinding); }
public void addProvisionListener(ProvisionListenerBinding provisionListenerBinding) { throw new UnsupportedOperationException(); }
public List<ProvisionListenerBinding> getProvisionListenerBindings() { return ImmutableList.of(); }
void addProvisionListener(ProvisionListenerBinding provisionListenerBinding);
List<ProvisionListenerBinding> getProvisionListenerBindings();