List of usage examples for java.lang.reflect ParameterizedType getActualTypeArguments
Type[] getActualTypeArguments();
From source file:org.craftercms.commerce.server.BaseCRUDService.java
@SuppressWarnings("unchecked") protected Class<T> getTypeArgument() { ParameterizedType parameterizedType = (ParameterizedType) getClass().getGenericSuperclass(); return (Class<T>) parameterizedType.getActualTypeArguments()[0]; }
From source file:org.jcurl.core.ui.TaskExecutorTest.java
public void testRTTI() { assertEquals(0, MessageBase1.class.getGenericInterfaces().length); assertEquals(// www . jav a 2 s . c o m "org.jcurl.core.ui.TaskExecutor.org.jcurl.core.ui.TaskExecutor$ForkableFixed<org.jcurl.core.ui.TaskExecutor$SwingEDT>", MessageBase1.class.getGenericSuperclass().toString()); ParameterizedType pt = (ParameterizedType) MessageBase1.class.getGenericSuperclass(); assertEquals(SwingEDT.class, pt.getActualTypeArguments()[0]); assertEquals(1, Message1.class.getGenericInterfaces().length); assertEquals(Object.class, Message1.class.getGenericSuperclass()); pt = (ParameterizedType) Message1.class.getGenericInterfaces()[0]; assertEquals(SwingEDT.class, pt.getActualTypeArguments()[0]); assertEquals(SwingEDT.class, TaskExecutor.findMessageTypeParam(Message1.class)); assertEquals(SwingEDT.class, TaskExecutor.findMessageTypeParam(MessageBase1.class)); }
From source file:dao.imp.AbstractHbnDao.java
private Class<T> getDomainClass() { if (domainClass == null) { ParameterizedType thisType = (ParameterizedType) getClass().getGenericSuperclass(); this.domainClass = (Class<T>) thisType.getActualTypeArguments()[0]; }/* w w w. j a v a 2 s . c o m*/ return domainClass; }
From source file:com.smhdemo.common.base.JpaDao.java
@SuppressWarnings("unchecked") public JpaDao() { ParameterizedType genericSuperclass = (ParameterizedType) getClass().getGenericSuperclass(); this.entityClass = (Class<E>) genericSuperclass.getActualTypeArguments()[1]; }
From source file:de.openknowledge.jaxrs.versioning.conversion.FieldVersionProperty.java
@Override public Class<?> getCollectionElementType() { // TODO improve generics resolution ParameterizedType type = (ParameterizedType) field.getGenericType(); return (Class<?>) type.getActualTypeArguments()[0]; }
From source file:org.devproof.portal.core.config.factory.DevproofClassPathBeanDefinitionScanner.java
/** * Entity class is always the first generic type * @param clazz type/*from w w w .j ava2 s . c o m*/ * @return entity class */ private Class<?> getEntityClazz(Class<?> clazz) { Type[] types = clazz.getGenericInterfaces(); ParameterizedType type = (ParameterizedType) types[0]; return (Class<?>) type.getActualTypeArguments()[0]; }
From source file:be.wolkmaan.klimtoren.persistence.HibernateRepository.java
private Class<T> genericClass() { ParameterizedType parameterizedType = (ParameterizedType) getClass().getGenericSuperclass(); @SuppressWarnings("unchecked") Class<T> ret = (Class<T>) parameterizedType.getActualTypeArguments()[0]; return ret;/* w w w.j a va2 s .c o m*/ }
From source file:emlab.repository.AbstractRepository.java
@SuppressWarnings("unchecked") public Class<T> getActualType() { ParameterizedType parameterizedType = (ParameterizedType) getClass().getGenericSuperclass(); return (Class<T>) parameterizedType.getActualTypeArguments()[0]; }
From source file:org.simbasecurity.manager.service.rest.resolver.JSonArgumentResolver.java
private Collection<?> readAsCollection(ObjectMapper objectMapper, JsonNode objectNode, MethodParameter methodParameter) throws Exception { Collection<Object> collection = (Collection<Object>) createCollection(methodParameter.getParameterType()); ParameterizedType type = (ParameterizedType) methodParameter.getGenericParameterType(); Class<?> actualType = (Class<?>) type.getActualTypeArguments()[0]; for (JsonNode jsonNode : objectNode) { collection.add(objectMapper.readValue(jsonNode, actualType)); }/* w w w. jav a2s. c om*/ return collection; }
From source file:ws.util.AbstractJSONCoder.java
@Override public void init(EndpointConfig endpointConfig) { ParameterizedType $thisClass = (ParameterizedType) this.getClass().getGenericSuperclass(); Type $T = $thisClass.getActualTypeArguments()[0]; if ($T instanceof Class) { type = (Class<T>) $T; } else if ($T instanceof ParameterizedType) { type = (Class<T>) ((ParameterizedType) $T).getRawType(); }// w w w . j a v a2 s .c om }