/** * @return the object which is was originally decorated and is not a decorator itself. */ @SuppressWarnings("unchecked") public static <T> T getOriginalDecoratedObject(final T object) { return (object instanceof ObjectDecorator) ? ((ObjectDecorator<T>) object).getOriginalDecoratedObject() : object; }
/** * Check for each field from the passed object if @Inject annotation is present & inject the required field if * supported, otherwise warns about invalid usage. * * @param object * to check for annotation presence. */ private void processInjectAnnotation(final Object object) { try { final Collection<Field> fields = getAllFields(object); for (final Field field : fields) { if (field.isAnnotationPresent(Inject.class)) { if (!acceptAnnotatedField(object, field)) { final String message = String.format( "@Inject cannot be applied on object: %s to field of type: %s using injector %s", object, field.getType(), this); LOG.error(message + ". Supported types are: {}", map.keySet()); throw new WroRuntimeException(message); } } } // handle special cases like decorators. Perform recursive injection if (object instanceof ObjectDecorator) { processInjectAnnotation(((ObjectDecorator<?>) object).getDecoratedObject()); } } catch (final Exception e) { LOG.error("Error while scanning @Inject annotation", e); throw WroRuntimeException.wrap(e, "Exception while trying to process @Inject annotation on object: " + object); } }
/** * Check for each field from the passed object if @Inject annotation is present & inject the required field if * supported, otherwise warns about invalid usage. * * @param object * to check for annotation presence. */ private void processInjectAnnotation(final Object object) { try { final Collection<Field> fields = getAllFields(object); for (final Field field : fields) { if (field.isAnnotationPresent(Inject.class)) { if (!acceptAnnotatedField(object, field)) { final String message = String.format( "@Inject cannot be applied on object: %s to field of type: %s using injector %s", object, field.getType(), this); LOG.error(message + ". Supported types are: {}", map.keySet()); throw new WroRuntimeException(message); } } } // handle special cases like decorators. Perform recursive injection if (object instanceof ObjectDecorator) { processInjectAnnotation(((ObjectDecorator<?>) object).getDecoratedObject()); } } catch (final Exception e) { LOG.error("Error while scanning @Inject annotation", e); throw WroRuntimeException.wrap(e, "Exception while trying to process @Inject annotation on object: " + object); } }
/** * @return the object which is was originally decorated and is not a decorator itself. */ @SuppressWarnings("unchecked") public static <T> T getOriginalDecoratedObject(final T object) { return (object instanceof ObjectDecorator) ? ((ObjectDecorator<T>) object).getOriginalDecoratedObject() : object; }