/** * Finds originating type for this field. * * @param propertyHierarchy * The fields to look through. * @return The true type. */ public static Type getRealType(final Member... propertyHierarchy) { final Deque<Member> properties = new LinkedList<Member>(); for (final Member property : propertyHierarchy) { properties.add(property); } return GenericsUtil.getRealType(properties); }
/** {@inheritDoc} */ @Override public void handleEvent(final UpdatedParameterEvent<P, B> event) throws EventException { SetParameterListener.LOGGER.debug("Handling event {}", event); Validate.notNull(event, "Event may not be null."); final AnnotationParameterDescriptorBuilder<P, B> builder = event.getBuilder(); final Deque<DescribedParameter<?>> params = new LinkedList<DescribedParameter<?>>(); params.add(event.getParameter()); final java.lang.reflect.Type type = GenericsUtil.getRealType(params); if (type instanceof Class) { builder.type((Class<?>) type); } else { builder.type(Object.class); } } }
/** {@inheritDoc} */ @Override public void handleEvent(final UpdatedPropertyTypeEvent<P, E, B> event) throws EventException { SetPropertyListener.LOGGER.debug("Handle event {}", event); Validate.notNull(event, "Event may not be null."); final AnnotationPropertyDescriptorBuilder<P, E, B> builder = event.getBuilder(); final java.lang.reflect.Type type = GenericsUtil.getRealType(builder.getBuilderContext().getAccessorContext() .getDescribedProperties()); if (type instanceof Class) { builder.type((Class<?>) type); } else { builder.type(Object.class); } } }
/** {@inheritDoc} */ @Override public void handleEvent(final UpdatedOperationReferenceEvent<E, B> event) throws EventException { SetResultListener.LOGGER.debug("Handling event {}", event); Validate.notNull(event, "Event may not be null."); final AnnotationOperationDescriptorBuilder<E, B> builder = event.getBuilder(); final Deque<Member> members = new LinkedList<Member>(); members.add(builder.getOperation()); members.addAll(builder.getBuilderContext().getAccessorContext().getDescribedProperties()); final java.lang.reflect.Type type = GenericsUtil.getRealType(members); final AnnotationResultDescriptorBuilder<R, E, B> resultDescriptor = builder.getResultBuilder(); if (type instanceof Class) { resultDescriptor.type((Class<?>) type); } else { final Class<?> guessedClazz = GenericsUtil.guessClazz(type); resultDescriptor.type(guessedClazz); } } }