@Test void shouldThrowForUnspecifiedGenerics() { ResolutionContext context = new ResolutionContext(injector, newIdentifier(Factory.class)); InjectorException ex = assertThrows(InjectorException.class, () -> getFactoryHandler().resolve(context)); assertThat(ex.getMessage(), containsString("Factory fields must have concrete generic type.")); }
@Override public Resolution<?> resolve(ResolutionContext context) { final Class<?> clazz = context.getIdentifier().getTypeAsClass(); if (Factory.class.equals(clazz)) { Class<?> genericType = ReflectionUtils.getGenericType(context.getIdentifier().getType()); if (genericType == null) { throw new InjectorException("Factory fields must have concrete generic type. " + "Cannot get generic type for field in '" + context.getIdentifier().getTypeAsClass() + "'"); } return new SimpleResolution<>(new FactoryImpl<>(genericType, context.getInjector())); } return null; }
FactoryDependencyHandler implements Handler { @Override public Resolution<?> resolve(ResolutionContext context) { final Class<?> clazz = context.getIdentifier().getTypeAsClass(); if (Factory.class.equals(clazz)) { Class<?> genericType = ReflectionUtils.getGenericType(context.getIdentifier().getType()); if (genericType == null) { throw new InjectorException("Factory fields must have concrete generic type. " + "Cannot get generic type for field in '" + context.getIdentifier().getTypeAsClass() + "'"); } return new SimpleResolution<>(new FactoryImpl<>(genericType, context.getInjector())); } return null; } }
FactoryDependencyHandler implements Handler { @Override public Resolution<?> resolve(ResolutionContext context) { final Class<?> clazz = context.getIdentifier().getTypeAsClass(); if (Factory.class.equals(clazz)) { Class<?> genericType = ReflectionUtils.getGenericType(context.getIdentifier().getType()); if (genericType == null) { throw new InjectorException("Factory fields must have concrete generic type. " + "Cannot get generic type for field in '" + context.getIdentifier().getTypeAsClass() + "'"); } return new SimpleResolution<>(new FactoryImpl<>(genericType, context.getInjector())); } return null; }  }
FactoryDependencyHandler implements Handler { @Override public Resolution<?> resolve(ResolutionContext context) { final Class<?> clazz = context.getIdentifier().getTypeAsClass(); if (Factory.class.equals(clazz)) { Class<?> genericType = ReflectionUtils.getGenericType(context.getIdentifier().getType()); if (genericType == null) { throw new InjectorException("Factory fields must have concrete generic type. " + "Cannot get generic type for field in '" + context.getIdentifier().getTypeAsClass() + "'"); } return new SimpleResolution<>(new FactoryImpl<>(genericType, context.getInjector())); } return null; }  @Override Resolution<?> resolve(ResolutionContext context); }
FactoryDependencyHandler implements Handler { @Override public Resolution<?> resolve(ResolutionContext context) { final Class<?> clazz = context.getIdentifier().getTypeAsClass(); if (Factory.class.equals(clazz)) { Class<?> genericType = ReflectionUtils.getGenericType(context.getIdentifier().getType()); if (genericType == null) { throw new InjectorException("Factory fields must have concrete generic type. " + "Cannot get generic type for field in '" + context.getIdentifier().getTypeAsClass() + "'"); } return new SimpleResolution<>(new FactoryImpl<>(genericType, context.getInjector())); } return null; }  @Override Resolution<?> resolve(ResolutionContext context);  }