@Override public synchronized void explore() { if (_explored) { return; } if (LOGGER.isDebugEnabled()) { LOGGER.debug("exploring iteratable type: {} gtype: {}", _class, _accessor.getGenericType()); } Type t = _accessor.getGenericType(); if (t instanceof ParameterizedType) { Type[] pt = ((ParameterizedType) t).getActualTypeArguments(); // First type is a child, ignore rest if (pt.length > 0) { _types.put(_name, new TypeInfo(_name, (Class)pt[0], null)); } } _explored = true; }
public TypeInfo getCollectionChild(Class<?> childType) { explore(); for (TypeInfo ti : _types.values()) { if (Collection.class.isAssignableFrom(ti.getType())) { ParameterizedType p = (ParameterizedType) ti.getAccessor().getGenericType(); Type[] pts = p.getActualTypeArguments(); if (pts.length == 1 && pts[0].equals(childType)) { return ti; } } } return null; }
@Override public synchronized void explore() { if (_explored) { return; } if (LOGGER.isDebugEnabled()) { LOGGER.debug("exploring wrapper type: {} gtype: {}", _class, _accessor.getGenericType()); } String tn = null; AccessibleObject accessibleObject = _accessor.getAccessibleObject(); XmlElement xmlElement = accessibleObject.getAnnotation(XmlElement.class); if (accessibleObject instanceof Field) { Field f = (Field) accessibleObject; tn = DEFAULT_NAME.equals(xmlElement.name())?f.getName() : xmlElement.name(); }else if (accessibleObject instanceof Method) { Method m = (Method) accessibleObject; tn = DEFAULT_NAME.equals(xmlElement.name())?m.getName() : xmlElement.name(); } this._types.put(tn, new IteratableTypeInfo(tn, this._accessor)); _explored = true; }