Annotation Interface XStreamConverter
Annotation to declare a converter. The annotation supports additionally the injection of
various constructor arguments provided by XStream:
Mapper
: The current mapper chain of the XStream instance.ClassLoaderReference
: The reference to the class loader used by the XStream instance to deserialize the objects.ReflectionProvider
: The reflection provider used by the reflection based converters of the current XStream instance.ConverterLookup
: The lookup for converters handling a special type.- All elements provided with the individual arrays of this annotation. The provided values follow the declaration sequence if a constructor requires multiple arguments of the same type.
Class
: The type of the element where the annotation is declared. Note, that this argument is not supported when usingXStreamConverters
oruseImplicitType()
== false.JVM
: Utility e.g. to load classes.ClassLoader
(deprecated since 1.4.5): The class loader used by the XStream instance to deserialize the objects. Use ClassLoaderReference as argument
The algorithm will try the converter's constructor with the most arguments first.
Note, the annotation matches a ConverterMatcher
.
Converter
as well as
SingleValueConverter
extend this interface. The
AnnotationMapper
can only handle these two
known types.
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionboolean[]
byte[]
char[]
double[]
float[]
int[]
long[]
Class<?>[]
Provide null types as arguments for the converter's constructor arguments.int
short[]
String[]
Class<?>[]
Provide class types as arguments for the converter's constructor arguments.boolean
Flag to provide the current type as implicit first Class argument to a converter's constructor.
-
Element Details
-
value
Class<? extends ConverterMatcher> value -
priority
int priority- Default:
0
-
useImplicitType
boolean useImplicitTypeFlag to provide the current type as implicit first Class argument to a converter's constructor.- Returns:
- true if the current type is provided
- Since:
- 1.4.5
- Default:
true
-
types
Class<?>[] typesProvide class types as arguments for the converter's constructor arguments.Note, that XStream itself provides the current class type as first Class argument to a constructor, if the annotation is added directly to a class type (and not as part of a parameter declaration of a
XStreamConverters
annotation). The current type has precedence over any type provided with this method. This behavior can be overridden settinguseImplicitType()
to false.- Returns:
- the types
- Since:
- 1.4.2
- Default:
{}
-
strings
String[] strings- Default:
{}
-
bytes
byte[] bytes- Default:
{}
-
chars
char[] chars- Default:
{}
-
shorts
short[] shorts- Default:
{}
-
ints
int[] ints- Default:
{}
-
longs
long[] longs- Default:
{}
-
floats
float[] floats- Default:
{}
-
doubles
double[] doubles- Default:
{}
-
booleans
boolean[] booleans- Default:
{}
-
nulls
Class<?>[] nullsProvide null types as arguments for the converter's constructor arguments.- Returns:
- the types provided as null values
- Since:
- 1.4.9
- Default:
{}
-