com.thoughtworks.xstream.annotations.XStreamConverter Java Examples
The following examples show how to use
com.thoughtworks.xstream.annotations.XStreamConverter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AnnotationMapper.java From lams with GNU General Public License v2.0 | 5 votes |
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()); } } } } }
Example #2
Source File: AnnotationMapper.java From lams with GNU General Public License v2.0 | 5 votes |
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); } } }