InjectionPoint(TypeLiteral<?> declaringType, Field field, boolean optional) { this.member = field; this.declaringType = declaringType; this.optional = optional; Annotation[] annotations = field.getAnnotations(); Errors errors = new Errors(field); Key<?> key = null; try { key = Annotations.getKey(declaringType.getFieldType(field), field, annotations, errors); } catch (ConfigurationException e) { errors.merge(e.getErrorMessages()); } catch (ErrorsException e) { errors.merge(e.getErrors()); } errors.throwConfigurationExceptionIfErrorsExist(); this.dependencies = ImmutableList.<Dependency<?>>of( newDependency(key, Nullability.allowsNull(annotations), -1)); }
@Override public Key<?> getKey(TypeLiteral<?> injectedType, Field injectedMember, A resourceAnnotation) { for (Annotation annotation : injectedMember.getAnnotations()) if (Annotations.isBindingAnnotation(annotation.annotationType())) return Key.get(injectedType.getFieldType(injectedMember), annotation); return Key.get(injectedType.getFieldType(injectedMember)); }
@Override public Key<?> getKey(TypeLiteral<?> injectedType, Field injectedMember, A resourceAnnotation) { for (Annotation annotation : injectedMember.getAnnotations()) if (Annotations.isBindingAnnotation(annotation.annotationType())) return Key.get(injectedType.getFieldType(injectedMember), annotation); return Key.get(injectedType.getFieldType(injectedMember)); }
@Override public Key<?> getKey(TypeLiteral<?> injectedType, Field injectedMember, A resourceAnnotation) { for (Annotation annotation : injectedMember.getAnnotations()) if (Annotations.isBindingAnnotation(annotation.annotationType())) return Key.get(injectedType.getFieldType(injectedMember), annotation); return Key.get(injectedType.getFieldType(injectedMember)); }
public Object provide(A annotation, TypeLiteral<?> type, Field field) { TypeLiteral<?> requiredType = type.getFieldType(field); return provide(annotation, field, requiredType, field.getType(), null); }
@Override public Key<?> getKey(TypeLiteral<?> injectedType, Field injectedMember, Resource resourceAnnotation) { String name = resourceAnnotation.name(); if (name.length() != 0) { // explicit key // if a name is provided, it acts as a Named binding and this means we ask for a precise key return Key.get(injectedType.getFieldType(injectedMember), Names.named(name)); } else { // implicit key // if no name given, try a combination with the field name Key<?> implicitKey = Key.get(injectedType.getFieldType(injectedMember), Names.named(injectedMember.getName())); if (injector.getExistingBinding(implicitKey) != null) { return implicitKey; } else { // else create the find based on the field type (default behavior) - with optional existing binding annotations return super.getKey(injectedType, injectedMember, resourceAnnotation); } } } }
@Override public Key<?> getKey(TypeLiteral<?> injectedType, Field injectedMember, Resource resourceAnnotation) { String name = resourceAnnotation.name(); if (name.length() != 0) { // explicit key // if a name is provided, it acts as a Named binding and this means we ask for a precise key return Key.get(injectedType.getFieldType(injectedMember), Names.named(name)); } else { // implicit key // if no name given, try a combination with the field name Key<?> implicitKey = Key.get(injectedType.getFieldType(injectedMember), Names.named(injectedMember.getName())); if (injector.getExistingBinding(implicitKey) != null) { return implicitKey; } else { // else create the find based on the field type (default behavior) - with optional existing binding annotations return super.getKey(injectedType, injectedMember, resourceAnnotation); } } } }
/** * Returns the field's type, if appropriate parametrized with the declaring * class's type parameters. * * @return field type */ public TypeLiteral<?> getFieldType() { return getDeclaringType().getFieldType(getMember()); }
InjectionPoint(TypeLiteral<?> declaringType, Field field, boolean optional) { this.member = field; this.declaringType = declaringType; this.optional = optional; Annotation[] annotations = field.getAnnotations(); Errors errors = new Errors(field); Key<?> key = null; try { key = Annotations.getKey(declaringType.getFieldType(field), field, annotations, errors); } catch (ConfigurationException e) { errors.merge(e.getErrorMessages()); } catch (ErrorsException e) { errors.merge(e.getErrors()); } errors.throwConfigurationExceptionIfErrorsExist(); this.dependencies = ImmutableList.<Dependency<?>>of( newDependency(key, Nullability.allowsNull(annotations), -1)); }
InjectionPoint(TypeLiteral<?> declaringType, Field field, boolean optional) { this.member = field; this.declaringType = declaringType; this.optional = optional; Annotation[] annotations = field.getAnnotations(); Errors errors = new Errors(field); Key<?> key = null; try { key = Annotations.getKey(declaringType.getFieldType(field), field, annotations, errors); } catch (ConfigurationException e) { errors.merge(e.getErrorMessages()); } catch (ErrorsException e) { errors.merge(e.getErrors()); } errors.throwConfigurationExceptionIfErrorsExist(); this.dependencies = ImmutableList.<Dependency<?>>of( newDependency(key, Nullability.allowsNull(annotations), -1)); }
InjectionPoint(TypeLiteral<?> declaringType, Field field, boolean optional) { this.member = field; this.declaringType = declaringType; this.optional = optional; Annotation[] annotations = field.getAnnotations(); Errors errors = new Errors(field); Key<?> key = null; try { key = Annotations.getKey(declaringType.getFieldType(field), field, annotations, errors); } catch (ConfigurationException e) { errors.merge(e.getErrorMessages()); } catch (ErrorsException e) { errors.merge(e.getErrors()); } errors.throwConfigurationExceptionIfErrorsExist(); this.dependencies = ImmutableList.<Dependency<?>>of( newDependency(key, Nullability.allowsNull(annotations), -1)); }
InjectionPoint(TypeLiteral<?> declaringType, Field field, boolean optional) { this.member = field; this.declaringType = declaringType; this.optional = optional; Annotation[] annotations = field.getAnnotations(); Errors errors = new Errors(field); Key<?> key = null; try { key = Annotations.getKey(declaringType.getFieldType(field), field, annotations, errors); } catch (ConfigurationException e) { errors.merge(e.getErrorMessages()); } catch (ErrorsException e) { errors.merge(e.getErrors()); } errors.throwConfigurationExceptionIfErrorsExist(); this.dependencies = ImmutableList.<Dependency<?>>of( newDependency(key, Nullability.allowsNull(annotations), -1)); }
InjectionPoint(TypeLiteral<?> declaringType, Field field, boolean optional) { this.member = field; this.declaringType = declaringType; this.optional = optional; Annotation[] annotations = field.getAnnotations(); Errors errors = new Errors(field); Key<?> key = null; try { key = Annotations.getKey(declaringType.getFieldType(field), field, annotations, errors); } catch (ConfigurationException e) { errors.merge(e.getErrorMessages()); } catch (ErrorsException e) { errors.merge(e.getErrors()); } errors.throwConfigurationExceptionIfErrorsExist(); this.dependencies = ImmutableList.<Dependency<?>>of( newDependency(key, Nullability.allowsNull(annotations), -1)); }
InjectionPoint(TypeLiteral<?> declaringType, Field field, boolean optional) { this.member = field; this.declaringType = declaringType; this.optional = optional; Annotation[] annotations = field.getAnnotations(); Errors errors = new Errors(field); Key<?> key = null; try { key = Annotations.getKey(declaringType.getFieldType(field), field, annotations, errors); } catch (ConfigurationException e) { errors.merge(e.getErrorMessages()); } catch (ErrorsException e) { errors.merge(e.getErrors()); } errors.throwConfigurationExceptionIfErrorsExist(); this.dependencies = ImmutableList.<Dependency<?>>of( newDependency(key, Nullability.allowsNull(annotations), -1)); }