@Test public void testGetCollectionComponentType() throws NoSuchMethodException { assertEquals(int.class, _typeInspector.getCollectionComponentType(int[].class)); var type = TestJavaTypeInspector.class.getMethod("test1").getGenericReturnType(); assertEquals(String.class, _typeInspector.getCollectionComponentType(type)); var type2 = TestJavaTypeInspector.class.getMethod("test2").getGenericReturnType(); assertEquals(type, _typeInspector.getCollectionComponentType(type2)); }
@Override public Type getCollectionComponentType(Type type) { if (!isCollection(type)) throw new RuntimeException(type.getTypeName() + " is not collection"); if (type instanceof Class) { var clazz = (Class)type; if (clazz.isArray()) { return clazz.getComponentType(); } if (Collection.class.isAssignableFrom(clazz)) { } } else if (type instanceof ParameterizedType) { var parameterizedType = (ParameterizedType)type; if (Collection.class.isAssignableFrom((Class<?>) parameterizedType.getRawType())) { return parameterizedType.getActualTypeArguments()[0]; } } return Object.class; }
JavaTypeInspector implements ITypeInspector { @Override public Type getCollectionComponentType(Type type) { if (!isCollection(type)) throw new RuntimeException(type.getTypeName() + " is not collection"); if (type instanceof Class) { var clazz = (Class)type; if (clazz.isArray()) { return clazz.getComponentType(); } if (Collection.class.isAssignableFrom(clazz)) { } } else if (type instanceof ParameterizedType) { var parameterizedType = (ParameterizedType)type; if (Collection.class.isAssignableFrom((Class<?>) parameterizedType.getRawType())) { return parameterizedType.getActualTypeArguments()[0]; } } return Object.class; } }
JavaTypeInspector implements ITypeInspector { @Override public Type getCollectionComponentType(Type type) { if (!isCollection(type)) throw new RuntimeException(type.getTypeName() + " is not collection"); if (type instanceof Class) { var clazz = (Class)type; if (clazz.isArray()) { return clazz.getComponentType(); } if (Collection.class.isAssignableFrom(clazz)) { } } else if (type instanceof ParameterizedType) { var parameterizedType = (ParameterizedType)type; if (Collection.class.isAssignableFrom((Class<?>) parameterizedType.getRawType())) { return parameterizedType.getActualTypeArguments()[0]; } } return Object.class; }  }
JavaTypeInspector implements ITypeInspector { @Override public Type getCollectionComponentType(Type type) { if (!isCollection(type)) throw new RuntimeException(type.getTypeName() + " is not collection"); if (type instanceof Class) { var clazz = (Class)type; if (clazz.isArray()) { return clazz.getComponentType(); } if (Collection.class.isAssignableFrom(clazz)) { } } else if (type instanceof ParameterizedType) { var parameterizedType = (ParameterizedType)type; if (Collection.class.isAssignableFrom((Class<?>) parameterizedType.getRawType())) { return parameterizedType.getActualTypeArguments()[0]; } } return Object.class; }  @Override boolean isSimpleType(Type type); @Override boolean isCollection(Type type); @Override Type getCollectionComponentType(Type type); @Override boolean isSupport(Type type); }
JavaTypeInspector implements ITypeInspector { @Override public Type getCollectionComponentType(Type type) { if (!isCollection(type)) throw new RuntimeException(type.getTypeName() + " is not collection"); if (type instanceof Class) { var clazz = (Class)type; if (clazz.isArray()) { return clazz.getComponentType(); } if (Collection.class.isAssignableFrom(clazz)) { } } else if (type instanceof ParameterizedType) { var parameterizedType = (ParameterizedType)type; if (Collection.class.isAssignableFrom((Class<?>) parameterizedType.getRawType())) { return parameterizedType.getActualTypeArguments()[0]; } } return Object.class; }  @Override boolean isSimpleType(Type type); @Override boolean isCollection(Type type); @Override Type getCollectionComponentType(Type type); @Override boolean isSupport(Type type);  }