public static Class<?> getTypeParameter(final Field field, final int parameterIndex) { final Type genericType = field.getGenericType(); return getTypeParameter(genericType, parameterIndex); }
@SuppressWarnings("unchecked") @Override public Class<C> getOutcomeCategoryEnum() { final Class<?> typeParameter = ReflectionUtils.getTypeParameter(getComponentClass(), Filter.class, 0); if (typeParameter == null) { throw new IllegalStateException("Could not determine Filter's category enum type"); } return (Class<C>) typeParameter; }
@Override public Class<?> getGenericTypeArgument(final int i) throws IndexOutOfBoundsException { return ReflectionUtils.getTypeParameter(getGenericType(), i); }
@Override public Class<?> getTypeArgument(final int i) throws IndexOutOfBoundsException { return ReflectionUtils.getTypeParameter(getField(), i); }
@SuppressWarnings("unchecked") @Override public <T extends JobContext> JobEngine<? extends T> getJobEngine(Class<T> jobContext) { final Collection<JobEngine<?>> jobEngines = getJobEngines(); for (JobEngine<?> jobEngine : jobEngines) { final Class<?> jobEngineTypeParameter = ReflectionUtils.getTypeParameter(jobEngine.getClass(), JobEngine.class, 0); if (ReflectionUtils.is(jobContext, jobEngineTypeParameter)) { return (JobEngine<? extends T>) jobEngine; } } return null; }
AbstractHasAnalyzerResultComponentDescriptor(final Class<B> beanClass, final boolean requireInputColumns) { super(beanClass, requireInputColumns); final Class<?> typeParameter = ReflectionUtils.getTypeParameter(getComponentClass(), HasAnalyzerResult.class, 0); @SuppressWarnings("unchecked") final Class<? extends AnalyzerResult> resultClass = (Class<? extends AnalyzerResult>) typeParameter; _resultDescriptor = Descriptors.ofResult(resultClass); }
protected AnnotationBasedRendererBeanDescriptor(final Class<R> rendererClass) throws DescriptorException { super(rendererClass, true); final RendererBean rendererBeanAnnotation = ReflectionUtils.getAnnotation(rendererClass, RendererBean.class); if (rendererBeanAnnotation == null) { throw new DescriptorException(rendererClass + " doesn't implement the RendererBean annotation"); } _renderingFormat = rendererBeanAnnotation.value(); if (_renderingFormat == null || _renderingFormat.isInterface() || Modifier .isAbstract(_renderingFormat.getModifiers())) { throw new DescriptorException("Rendering format (" + _renderingFormat + ") is not a non-abstract class"); } _formatOutputType = ReflectionUtils.getTypeParameter(_renderingFormat, RenderingFormat.class, 0); logger.debug("Found format output type: {}", _formatOutputType); if (_formatOutputType == null) { throw new DescriptorException("Could not determine output type of rendering format: " + _renderingFormat); } @SuppressWarnings("unchecked") final Class<? extends Renderable> rendererInputType = (Class<? extends Renderable>) ReflectionUtils.getTypeParameter(rendererClass, Renderer.class, 0); _rendererInputType = rendererInputType; logger.debug("Found renderer input type: {}", _rendererInputType); _rendererOutputType = ReflectionUtils.getTypeParameter(rendererClass, Renderer.class, 1); logger.debug("Found renderer output type: {}", _rendererOutputType); if (_rendererOutputType == null) { throw new DescriptorException("Could not determine output type of renderer: " + rendererClass); } if (!ReflectionUtils.is(_rendererOutputType, _formatOutputType)) { throw new DescriptorException("The renderer output type (" + _rendererOutputType + ") is not a valid instance or sub-class of format output type (" + _formatOutputType + ")"); } }