in xstream/src/java/com/thoughtworks/xstream/mapper/AnnotationMapper.java [360:391]
private void processImplicitAnnotation(final Field field) {
final XStreamImplicit implicitAnnotation = field.getAnnotation(XStreamImplicit.class);
if (implicitAnnotation != null) {
if (implicitCollectionMapper == null) {
throw new InitializationException("No " + ImplicitCollectionMapper.class.getName() + " available");
}
final String fieldName = field.getName();
final String itemFieldName = implicitAnnotation.itemFieldName();
final String keyFieldName = implicitAnnotation.keyFieldName();
final boolean isMap = Map.class.isAssignableFrom(field.getType());
Class<?> itemType = null;
if (!field.getType().isArray()) {
final Type genericType = field.getGenericType();
if (genericType instanceof ParameterizedType) {
final Type[] actualTypeArguments = ((ParameterizedType)genericType).getActualTypeArguments();
final Type typeArgument = actualTypeArguments[isMap ? 1 : 0];
itemType = getClass(typeArgument);
}
}
if (isMap) {
implicitCollectionMapper.add(field.getDeclaringClass(), fieldName, itemFieldName != null
&& !"".equals(itemFieldName) ? itemFieldName : null, itemType, keyFieldName != null
&& !"".equals(keyFieldName) ? keyFieldName : null);
} else {
if (itemFieldName != null && !"".equals(itemFieldName)) {
implicitCollectionMapper.add(field.getDeclaringClass(), fieldName, itemFieldName, itemType);
} else {
implicitCollectionMapper.add(field.getDeclaringClass(), fieldName, itemType);
}
}
}
}