/** * Attempts to create a just-in-time binding for {@code key} in the root injector, falling back to * other ancestor injectors until this injector is tried. */ private <T> BindingImpl<T> createJustInTimeBindingRecursive(Key<T> key, Errors errors) throws ErrorsException { if (state.isBlacklisted(key)) { throw errors.childBindingAlreadySet(key).toException(); } BindingImpl<T> binding = createJustInTimeBinding(key, errors); state.parent().blacklist(key); jitBindings.put(key, binding); return binding; }
@Override public MatcherAndConverter getConverter( String stringValue, TypeLiteral<?> type, Errors errors, Object source) { MatcherAndConverter matchingConverter = null; for (State s = this; s != State.NONE; s = s.parent()) { for (MatcherAndConverter converter : s.getConvertersThisLevel()) { if (converter.getTypeMatcher().matches(type)) { if (matchingConverter != null) { errors.ambiguousTypeConversion(stringValue, source, type, matchingConverter, converter); } matchingConverter = converter; } } } return matchingConverter; }
private void putBinding(BindingImpl<?> binding) { Key<?> key = binding.getKey(); Class<?> rawType = key.getRawType(); if (FORBIDDEN_TYPES.contains(rawType)) { errors.cannotBindToGuiceType(rawType.getSimpleName()); return; } Binding<?> original = injector.state.getExplicitBinding(key); if (original != null && !isOkayDuplicate(original, binding)) { errors.bindingAlreadySet(key, original.getSource()); return; } // prevent the parent from creating a JIT binding for this key injector.state.parent().blacklist(key); injector.state.putBinding(key, binding); }
/** * Attempts to create a just-in-time binding for {@code key} in the root injector, falling back to * other ancestor injectors until this injector is tried. */ private <T> BindingImpl<T> createJustInTimeBindingRecursive(Key<T> key, Errors errors) throws ErrorsException { if (state.isBlacklisted(key)) { throw errors.childBindingAlreadySet(key).toException(); } BindingImpl<T> binding = createJustInTimeBinding(key, errors); state.parent().blacklist(key); jitBindings.put(key, binding); return binding; }
/** * Attempts to create a just-in-time binding for {@code key} in the root injector, falling back to * other ancestor injectors until this injector is tried. */ private <T> BindingImpl<T> createJustInTimeBindingRecursive(Key<T> key, Errors errors) throws ErrorsException { if (state.isBlacklisted(key)) { throw errors.childBindingAlreadySet(key).toException(); } BindingImpl<T> binding = createJustInTimeBinding(key, errors); state.parent().blacklist(key); jitBindings.put(key, binding); return binding; }
/** * Attempts to create a just-in-time binding for {@code key} in the root injector, falling back to * other ancestor injectors until this injector is tried. */ private <T> BindingImpl<T> createJustInTimeBindingRecursive(Key<T> key, Errors errors) throws ErrorsException { if (state.isBlacklisted(key)) { throw errors.childBindingAlreadySet(key).toException(); } BindingImpl<T> binding = createJustInTimeBinding(key, errors); state.parent().blacklist(key); jitBindings.put(key, binding); return binding; }
@Override public MatcherAndConverter getConverter( String stringValue, TypeLiteral<?> type, Errors errors, Object source) { MatcherAndConverter matchingConverter = null; for (State s = this; s != State.NONE; s = s.parent()) { for (MatcherAndConverter converter : s.getConvertersThisLevel()) { if (converter.getTypeMatcher().matches(type)) { if (matchingConverter != null) { errors.ambiguousTypeConversion(stringValue, source, type, matchingConverter, converter); } matchingConverter = converter; } } } return matchingConverter; }
@Override public MatcherAndConverter getConverter( String stringValue, TypeLiteral<?> type, Errors errors, Object source) { MatcherAndConverter matchingConverter = null; for (State s = this; s != State.NONE; s = s.parent()) { for (MatcherAndConverter converter : s.getConvertersThisLevel()) { if (converter.getTypeMatcher().matches(type)) { if (matchingConverter != null) { errors.ambiguousTypeConversion(stringValue, source, type, matchingConverter, converter); } matchingConverter = converter; } } } return matchingConverter; }
@Override public MatcherAndConverter getConverter( String stringValue, TypeLiteral<?> type, Errors errors, Object source) { MatcherAndConverter matchingConverter = null; for (State s = this; s != State.NONE; s = s.parent()) { for (MatcherAndConverter converter : s.getConvertersThisLevel()) { if (converter.getTypeMatcher().matches(type)) { if (matchingConverter != null) { errors.ambiguousTypeConversion(stringValue, source, type, matchingConverter, converter); } matchingConverter = converter; } } } return matchingConverter; }
@Override public MatcherAndConverter getConverter( String stringValue, TypeLiteral<?> type, Errors errors, Object source) { MatcherAndConverter matchingConverter = null; for (State s = this; s != State.NONE; s = s.parent()) { for (MatcherAndConverter converter : s.getConvertersThisLevel()) { if (converter.getTypeMatcher().matches(type)) { if (matchingConverter != null) { errors.ambiguousTypeConversion(stringValue, source, type, matchingConverter, converter); } matchingConverter = converter; } } } return matchingConverter; }
private void putBinding(BindingImpl<?> binding) { Key<?> key = binding.getKey(); Class<?> rawType = key.getRawType(); if (FORBIDDEN_TYPES.contains(rawType)) { errors.cannotBindToGuiceType(rawType.getSimpleName()); return; } Binding<?> original = injector.state.getExplicitBinding(key); if (original != null && !isOkayDuplicate(original, binding)) { errors.bindingAlreadySet(key, original.getSource()); return; } // prevent the parent from creating a JIT binding for this key injector.state.parent().blacklist(key); injector.state.putBinding(key, binding); }
private void putBinding(BindingImpl<?> binding) { Key<?> key = binding.getKey(); Class<?> rawType = key.getRawType(); if (FORBIDDEN_TYPES.contains(rawType)) { errors.cannotBindToGuiceType(rawType.getSimpleName()); return; } Binding<?> original = injector.state.getExplicitBinding(key); if (original != null && !isOkayDuplicate(original, binding)) { errors.bindingAlreadySet(key, original.getSource()); return; } // prevent the parent from creating a JIT binding for this key injector.state.parent().blacklist(key); injector.state.putBinding(key, binding); }
private void putBinding(BindingImpl<?> binding) { Key<?> key = binding.getKey(); Class<?> rawType = key.getRawType(); if (FORBIDDEN_TYPES.contains(rawType)) { errors.cannotBindToGuiceType(rawType.getSimpleName()); return; } Binding<?> original = injector.state.getExplicitBinding(key); if (original != null && !isOkayDuplicate(original, binding)) { errors.bindingAlreadySet(key, original.getSource()); return; } // prevent the parent from creating a JIT binding for this key injector.state.parent().blacklist(key); injector.state.putBinding(key, binding); }
private void putBinding(BindingImpl<?> binding) { Key<?> key = binding.getKey(); Class<?> rawType = key.getRawType(); if (FORBIDDEN_TYPES.contains(rawType)) { errors.cannotBindToGuiceType(rawType.getSimpleName()); return; } Binding<?> original = injector.state.getExplicitBinding(key); if (original != null && !isOkayDuplicate(original, binding)) { errors.bindingAlreadySet(key, original.getSource()); return; } // prevent the parent from creating a JIT binding for this key injector.state.parent().blacklist(key); injector.state.putBinding(key, binding); }
/** * Attempts to create a just-in-time binding for {@code key} in the root injector, falling back to * other ancestor injectors until this injector is tried. */ private <T> BindingImpl<T> createJustInTimeBindingRecursive(Key<T> key, Errors errors) throws ErrorsException { // ask the parent to create the JIT binding if (parent != null && !parent.readOnly /* ES: don't check on parent if its read only, its already created all the bindings it can*/) { try { return parent.createJustInTimeBindingRecursive(key, new Errors()); } catch (ErrorsException ignored) { } } if (state.isBlacklisted(key)) { throw errors.childBindingAlreadySet(key).toException(); } BindingImpl<T> binding = createJustInTimeBinding(key, errors); state.parent().blacklist(key); jitBindings.put(key, binding); return binding; }