List of usage examples for java.lang.reflect ParameterizedType getActualTypeArguments
Type[] getActualTypeArguments();
From source file:by.creepid.docsreporter.context.meta.ListMetadataFiller.java
@Override public void fillMetadata(FieldsMetadata metadataToFill, Class<?> modelClass, String modelName, Map<String, Class<?>> iterationNames) { Map<String, Field> result = FieldHelper.getFieldsOfClass(Collection.class, modelClass, modelName, true); for (Map.Entry<String, Field> entry : result.entrySet()) { ParameterizedType collectionType = (ParameterizedType) entry.getValue().getGenericType(); Class<?> actualTypeArg = (Class<?>) collectionType.getActualTypeArguments()[0]; List<String> hierarchy = FieldHelper.getFieldHierarchy(actualTypeArg, entry.getKey()); for (String path : hierarchy) { metadataToFill.addFieldAsList(path); }/*from ww w . ja v a 2s.c o m*/ } }
From source file:org.broadleafcommerce.openadmin.server.service.persistence.module.provider.AbstractFieldPersistenceProvider.java
protected Class<?> getMapFieldType(Serializable instance, FieldManager fieldManager, Property property, PersistenceManager persistenceManager) { Class<?> returnType = null; Field field = fieldManager.getField(instance.getClass(), property.getName().substring(0, property.getName().indexOf(FieldManager.MAPFIELDSEPARATOR))); java.lang.reflect.Type type = field.getGenericType(); if (type instanceof ParameterizedType) { ParameterizedType pType = (ParameterizedType) type; Class<?> clazz = (Class<?>) pType.getActualTypeArguments()[1]; Class<?>[] entities = persistenceManager.getDynamicEntityDao() .getAllPolymorphicEntitiesFromCeiling(clazz); if (!ArrayUtils.isEmpty(entities)) { returnType = entities[entities.length - 1]; }// w w w .ja va2 s . c om } return returnType; }
From source file:org.appverse.web.framework.backend.ecm.filesystem.services.integration.impl.live.FileSystemDocumentService.java
private Class<T> getClassP() { Class<T> classP = null; final Type type = this.getClass().getGenericSuperclass(); if (type instanceof ParameterizedType) { final ParameterizedType pType = (ParameterizedType) type; if (pType.getActualTypeArguments()[0] instanceof Class) { classP = (Class<T>) pType.getActualTypeArguments()[0]; }/*from w w w . ja v a 2s . com*/ } return classP; }
From source file:com.google.gwt.sample.dynatablemvp.server.loc.SpringServiceLocator.java
@SuppressWarnings("unchecked") public SpringServiceLocator() { Type genSup = getClass().getGenericSuperclass(); if (genSup instanceof ParameterizedType) { ParameterizedType genericSuperclass = (ParameterizedType) getClass().getGenericSuperclass(); this.entityClass = (Class<E>) genericSuperclass.getActualTypeArguments()[0]; } else/*from w w w . j ava 2 s. c om*/ this.entityClass = null; }
From source file:org.apache.sling.models.impl.injectors.ChildResourceInjector.java
private Class<?> getActualType(ParameterizedType declaredType) { Type[] types = declaredType.getActualTypeArguments(); if (types != null && types.length > 0) { return (Class<?>) types[0]; }//from w w w .ja v a2s.c o m return null; }
From source file:ru.codemine.ccms.dao.GenericDAOImpl.java
public GenericDAOImpl() { ParameterizedType genericSuperclass = (ParameterizedType) getClass().getGenericSuperclass(); this.entityClass = (Class<T>) genericSuperclass.getActualTypeArguments()[0]; }
From source file:org.zkybase.cmdb.test.AbstractBeanTestCase.java
@SuppressWarnings("unchecked") public AbstractBeanTestCase() { ParameterizedType superclass = (ParameterizedType) getClass().getGenericSuperclass(); this.beanClass = (Class<T>) superclass.getActualTypeArguments()[0]; }
From source file:com.ebay.pulsar.analytics.dao.mapper.BaseDBMapper.java
@SuppressWarnings("unchecked") public BaseDBMapper() { ParameterizedType pt = (ParameterizedType) this.getClass().getGenericSuperclass(); clazz = (Class<T>) pt.getActualTypeArguments()[0]; }
From source file:org.etk.core.rest.impl.provider.MultipartFormDataEntityProvider.java
/** * {@inheritDoc}//from w w w.j av a2 s . c o m */ public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { if (type == Iterator.class) { try { ParameterizedType t = (ParameterizedType) genericType; Type[] ta = t.getActualTypeArguments(); if (ta.length == 1 && ta[0] == FileItem.class) { return true; } return false; } catch (ClassCastException e) { return false; } } return false; }
From source file:net.sf.gazpachoquest.services.core.impl.AbstractLocalizedPersistenceService.java
@SuppressWarnings("unchecked") private Class<L> getTypeParameterClass() { Type type = getClass().getGenericSuperclass(); ParameterizedType paramType = (ParameterizedType) type; return (Class<L>) paramType.getActualTypeArguments()[0]; }