addParametrizedTypes(type, types); processConverterAnnotations(type); processAliasAnnotation(type, types); processAliasTypeAnnotation(type); processImplicitCollectionAnnotation(type); addParametrizedTypes(field.getGenericType(), types); processFieldAliasAnnotation(field); processAsAttributeAnnotation(field); processImplicitAnnotation(field); processOmitFieldAnnotation(field); processLocalConverterAnnotation(field);
private void processLocalConverterAnnotation(final Field field) { final XStreamConverter annotation = field.getAnnotation(XStreamConverter.class); if (annotation != null) { final Converter converter = cacheConverter(annotation, field.getType()); if (converter != null) { if (localConversionMapper == null) { throw new InitializationException("No " + LocalConversionMapper.class.getName() + " available"); } localConversionMapper.registerLocalConverter( field.getDeclaringClass(), field.getName(), converter); } } }
.getActualTypeArguments(); final Type typeArgument = actualTypeArguments[isMap ? 1 : 0]; itemType = getClass(typeArgument);
@Override public Class defaultImplementationOf(final Class type) { if (!locked) { processAnnotations(type); } final Class defaultImplementation = super.defaultImplementationOf(type); if (!locked) { processAnnotations(defaultImplementation); } return defaultImplementation; }
private void setupMappers() { classAliasingMapper = (ClassAliasingMapper)lookupMapperOfType(ClassAliasingMapper.class); defaultImplementationsMapper = (DefaultImplementationsMapper)lookupMapperOfType(DefaultImplementationsMapper.class); implicitCollectionMapper = (ImplicitCollectionMapper)lookupMapperOfType(ImplicitCollectionMapper.class); fieldAliasingMapper = (FieldAliasingMapper)lookupMapperOfType(FieldAliasingMapper.class); elementIgnoringMapper = (ElementIgnoringMapper)lookupMapperOfType(ElementIgnoringMapper.class); attributeMapper = (AttributeMapper)lookupMapperOfType(AttributeMapper.class); localConversionMapper = (LocalConversionMapper)lookupMapperOfType(LocalConversionMapper.class); }
@Override public String realMember(final Class type, final String serialized) { if (!locked) { processAnnotations(type); } return super.realMember(type, serialized); }
private void setupMappers() { classAliasingMapper = lookupMapperOfType(ClassAliasingMapper.class); defaultImplementationsMapper = lookupMapperOfType(DefaultImplementationsMapper.class); implicitCollectionMapper = lookupMapperOfType(ImplicitCollectionMapper.class); fieldAliasingMapper = lookupMapperOfType(FieldAliasingMapper.class); elementIgnoringMapper = lookupMapperOfType(ElementIgnoringMapper.class); attributeMapper = lookupMapperOfType(AttributeMapper.class); localConversionMapper = lookupMapperOfType(LocalConversionMapper.class); }
addParametrizedTypes(type, types); processConverterAnnotations(type); processAliasAnnotation(type, types); processImplicitCollectionAnnotation(type); addParametrizedTypes(field.getGenericType(), types); processFieldAliasAnnotation(field); processAsAttributeAnnotation(field); processImplicitAnnotation(field); processOmitFieldAnnotation(field); processLocalConverterAnnotation(field);
@Override public Converter getLocalConverter(final Class definedIn, final String fieldName) { if (!locked) { processAnnotations(definedIn); } return super.getLocalConverter(definedIn, fieldName); }
private void processConverterAnnotations(final Class<?> type) { if (converterRegistry != null) { final XStreamConverters convertersAnnotation = type .getAnnotation(XStreamConverters.class); final XStreamConverter converterAnnotation = type .getAnnotation(XStreamConverter.class); final List<XStreamConverter> annotations = convertersAnnotation != null ? new ArrayList<XStreamConverter>(Arrays.asList(convertersAnnotation.value())) : new ArrayList<XStreamConverter>(); if (converterAnnotation != null) { annotations.add(converterAnnotation); } for (final XStreamConverter annotation : annotations) { final Converter converter = cacheConverter( annotation, converterAnnotation != null ? type : null); if (converter != null) { if (converterAnnotation != null || converter.canConvert(type)) { converterRegistry.registerConverter(converter, annotation.priority()); } else { throw new InitializationException("Converter " + annotation.value().getName() + " cannot handle annotated class " + type.getName()); } } } } }
final Type typeArgument = ((ParameterizedType)genericType) .getActualTypeArguments()[0]; itemType = getClass(typeArgument);
private void setupMappers() { classAliasingMapper = (ClassAliasingMapper)lookupMapperOfType(ClassAliasingMapper.class); defaultImplementationsMapper = (DefaultImplementationsMapper)lookupMapperOfType(DefaultImplementationsMapper.class); implicitCollectionMapper = (ImplicitCollectionMapper)lookupMapperOfType(ImplicitCollectionMapper.class); fieldAliasingMapper = (FieldAliasingMapper)lookupMapperOfType(FieldAliasingMapper.class); elementIgnoringMapper = (ElementIgnoringMapper)lookupMapperOfType(ElementIgnoringMapper.class); attributeMapper = (AttributeMapper)lookupMapperOfType(AttributeMapper.class); localConversionMapper = (LocalConversionMapper)lookupMapperOfType(LocalConversionMapper.class); }
addParametrizedTypes(type, types); processConverterAnnotations(type); processAliasAnnotation(type, types); processImplicitCollectionAnnotation(type); addParametrizedTypes(field.getGenericType(), types); processFieldAliasAnnotation(field); processAsAttributeAnnotation(field); processImplicitAnnotation(field); processOmitFieldAnnotation(field); processLocalConverterAnnotation(field);
@Override public String serializedClass(final Class type) { if (!locked) { processAnnotations(type); } return super.serializedClass(type); }
private void processLocalConverterAnnotation(final Field field) { final XStreamConverter annotation = field.getAnnotation(XStreamConverter.class); if (annotation != null) { final Converter converter = cacheConverter(annotation, field.getType()); if (converter != null) { if (localConversionMapper == null) { throw new InitializationException("No " + LocalConversionMapper.class.getName() + " available"); } localConversionMapper.registerLocalConverter(field.getDeclaringClass(), field.getName(), converter); } } }
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(); Class itemType = null; final Type genericType = field.getGenericType(); if (genericType instanceof ParameterizedType) { final Type typeArgument = ((ParameterizedType)genericType) .getActualTypeArguments()[0]; itemType = getClass(typeArgument); } if (itemFieldName != null && !"".equals(itemFieldName)) { implicitCollectionMapper.add( field.getDeclaringClass(), fieldName, itemFieldName, itemType); } else { implicitCollectionMapper.add(field.getDeclaringClass(), fieldName, itemType); } } }
private void setupMappers() { classAliasingMapper = (ClassAliasingMapper)lookupMapperOfType(ClassAliasingMapper.class); defaultImplementationsMapper = (DefaultImplementationsMapper)lookupMapperOfType(DefaultImplementationsMapper.class); implicitCollectionMapper = (ImplicitCollectionMapper)lookupMapperOfType(ImplicitCollectionMapper.class); fieldAliasingMapper = (FieldAliasingMapper)lookupMapperOfType(FieldAliasingMapper.class); elementIgnoringMapper = (ElementIgnoringMapper)lookupMapperOfType(ElementIgnoringMapper.class); attributeMapper = (AttributeMapper)lookupMapperOfType(AttributeMapper.class); localConversionMapper = (LocalConversionMapper)lookupMapperOfType(LocalConversionMapper.class); }
addParametrizedTypes(type, types); processConverterAnnotations(type); processAliasAnnotation(type, types); processAliasTypeAnnotation(type); addParametrizedTypes(field.getGenericType(), types); processFieldAliasAnnotation(field); processAsAttributeAnnotation(field); processImplicitAnnotation(field); processOmitFieldAnnotation(field); processLocalConverterAnnotation(field);
@Override public Class defaultImplementationOf(final Class type) { if (!locked) { processAnnotations(type); } final Class defaultImplementation = super.defaultImplementationOf(type); if (!locked) { processAnnotations(defaultImplementation); } return defaultImplementation; }
private void processLocalConverterAnnotation(final Field field) { final XStreamConverter annotation = field.getAnnotation(XStreamConverter.class); if (annotation != null) { final Converter converter = cacheConverter(annotation, field.getType()); if (converter != null) { if (localConversionMapper == null) { throw new InitializationException("No " + LocalConversionMapper.class.getName() + " available"); } localConversionMapper.registerLocalConverter( field.getDeclaringClass(), field.getName(), converter); } } }