@Override public BindingImpl<T> withScoping(Scoping scoping) { return new LinkedBindingImpl<T>(getSource(), getKey(), scoping, targetKey); }
@Override public BindingImpl<T> withKey(Key<T> key) { return new LinkedBindingImpl<T>(getSource(), key, getScoping(), targetKey); }
@Override public BindingBuilder<T> to(Key<? extends T> linkedKey) { checkNotNull(linkedKey, "linkedKey"); checkNotTargetted(); BindingImpl<T> base = getBinding(); setBinding( new LinkedBindingImpl<T>(base.getSource(), base.getKey(), base.getScoping(), linkedKey)); return this; }
/** Creates a binding for a type annotated with @ImplementedBy. */ private <T> BindingImpl<T> createImplementedByBinding( Key<T> key, Scoping scoping, ImplementedBy implementedBy, Errors errors) throws ErrorsException { Class<?> rawType = key.getTypeLiteral().getRawType(); Class<?> implementationType = implementedBy.value(); // Make sure it's not the same type. TODO: Can we check for deeper cycles? if (implementationType == rawType) { throw errors.recursiveImplementationType().toException(); } // Make sure implementationType extends type. if (!rawType.isAssignableFrom(implementationType)) { throw errors.notASubtype(implementationType, rawType).toException(); } @SuppressWarnings("unchecked") // After the preceding check, this cast is safe. Class<? extends T> subclass = (Class<? extends T>) implementationType; // Look up the target binding. final Key<? extends T> targetKey = Key.get(subclass); Object source = rawType; FactoryProxy<T> factory = new FactoryProxy<>(this, key, targetKey, source); factory.notify(errors); // causes the factory to initialize itself internally return new LinkedBindingImpl<T>( this, key, source, Scoping.<T>scope(key, this, factory, source, scoping), scoping, targetKey); }
@Override public Boolean visit(LinkedKeyBinding<? extends T> binding) { prepareBinding(); Key<? extends T> linkedKey = binding.getLinkedKey(); if (key.equals(linkedKey)) { errors.recursiveBinding(); } FactoryProxy<T> factory = new FactoryProxy<>(injector, key, linkedKey, source); bindingData.addCreationListener(factory); InternalFactory<? extends T> scopedFactory = Scoping.scope(key, injector, factory, source, scoping); putBinding( new LinkedBindingImpl<T>(injector, key, source, scopedFactory, scoping, linkedKey)); return true; }
public BindingImpl<T> withScoping(Scoping scoping) { return new LinkedBindingImpl<T>(getSource(), getKey(), scoping, targetKey); }
public BindingImpl<T> withScoping(Scoping scoping) { return new LinkedBindingImpl<T>(getSource(), getKey(), scoping, targetKey); }
@Override public BindingImpl<T> withKey(Key<T> key) { return new LinkedBindingImpl<T>(getSource(), key, getScoping(), targetKey); }
public BindingImpl<T> withKey(Key<T> key) { return new LinkedBindingImpl<T>(getSource(), key, getScoping(), targetKey); }
public BindingImpl<T> withKey(Key<T> key) { return new LinkedBindingImpl<T>(getSource(), key, getScoping(), targetKey); }
@Override public BindingImpl<T> withScoping(Scoping scoping) { return new LinkedBindingImpl<T>(getSource(), getKey(), scoping, targetKey); }
@Override public BindingImpl<T> withKey(Key<T> key) { return new LinkedBindingImpl<T>(getSource(), key, getScoping(), targetKey); }
public BindingImpl<T> withKey(Key<T> key) { return new LinkedBindingImpl<T>(getSource(), key, getScoping(), targetKey); }
@Override public BindingBuilder<T> to(Key<? extends T> linkedKey) { checkNotNull(linkedKey, "linkedKey"); checkNotTargetted(); BindingImpl<T> base = getBinding(); setBinding( new LinkedBindingImpl<T>(base.getSource(), base.getKey(), base.getScoping(), linkedKey)); return this; }
@Override public BindingBuilder<T> to(Key<? extends T> linkedKey) { checkNotNull(linkedKey, "linkedKey"); checkNotTargetted(); BindingImpl<T> base = getBinding(); setBinding( new LinkedBindingImpl<T>(base.getSource(), base.getKey(), base.getScoping(), linkedKey)); return this; }
public BindingBuilder<T> to(Key<? extends T> linkedKey) { checkNotNull(linkedKey, "linkedKey"); checkNotTargetted(); BindingImpl<T> base = getBinding(); setBinding(new LinkedBindingImpl<T>( base.getSource(), base.getKey(), base.getScoping(), linkedKey)); return this; }
public BindingBuilder<T> to(Key<? extends T> linkedKey) { checkNotNull(linkedKey, "linkedKey"); checkNotTargetted(); BindingImpl<T> base = getBinding(); setBinding(new LinkedBindingImpl<T>( base.getSource(), base.getKey(), base.getScoping(), linkedKey)); return this; }
public BindingBuilder<T> to(Key<? extends T> linkedKey) { checkNotNull(linkedKey, "linkedKey"); checkNotTargetted(); BindingImpl<T> base = getBinding(); setBinding(new LinkedBindingImpl<T>( base.getSource(), base.getKey(), base.getScoping(), linkedKey)); return this; }
public BindingBuilder<T> to(Key<? extends T> linkedKey) { checkNotNull(linkedKey, "linkedKey"); checkNotTargetted(); BindingImpl<T> base = getBinding(); setBinding(new LinkedBindingImpl<T>( base.getSource(), base.getKey(), base.getScoping(), linkedKey)); return this; }
public Boolean visit(LinkedKeyBinding<? extends T> binding) { prepareBinding(); Key<? extends T> linkedKey = binding.getLinkedKey(); if (key.equals(linkedKey)) { errors.recursiveBinding(); } FactoryProxy<T> factory = new FactoryProxy<T>(injector, key, linkedKey, source); bindingData.addCreationListener(factory); InternalFactory<? extends T> scopedFactory = Scoping.scope(key, injector, factory, source, scoping); putBinding( new LinkedBindingImpl<T>(injector, key, source, scopedFactory, scoping, linkedKey)); return true; }