private void setElementClassName(CollectionDescriptor collectionDescriptor, Type type) { if (type instanceof ParameterizedType) { Type[] paramType = ((ParameterizedType) type).getActualTypeArguments(); //TODO : change this condition. No sure if it will be all the time true. // If only one type argument, the object is certainly a collection if (paramType.length == 1) { collectionDescriptor.setElementClassName(paramType[0].toString().replace("class ", "").replace("interface ", "")); } // either, it is certainly a map else { collectionDescriptor.setElementClassName(paramType[1].toString().replace("class ", "").replace("interface ", "")); } } else { Type ancestorType = ((Class)type).getGenericSuperclass(); if ( ancestorType!= null) { setElementClassName(collectionDescriptor,ancestorType); } else{ collectionDescriptor.setElementClassName(Object.class.getName()); } } }
private void setElementClassName(CollectionDescriptor collectionDescriptor, Type type) { if (type instanceof ParameterizedType) { Type[] paramType = ((ParameterizedType) type).getActualTypeArguments(); //TODO : change this condition. No sure if it will be all the time true. // If only one type argument, the object is certainly a collection if (paramType.length == 1) { collectionDescriptor.setElementClassName(paramType[0].toString().replace("class ", "").replace("interface ", "")); } // either, it is certainly a map else { collectionDescriptor.setElementClassName(paramType[1].toString().replace("class ", "").replace("interface ", "")); } } else { Type ancestorType = ((Class)type).getGenericSuperclass(); if ( ancestorType!= null) { setElementClassName(collectionDescriptor,ancestorType); } else{ collectionDescriptor.setElementClassName(Object.class.getName()); } } }
setElementClassName(collectionDescriptor, field.getGenericType());
setElementClassName(collectionDescriptor, field.getGenericType());