Annotation Type XStreamConverter


  • @Retention(RUNTIME)
    @Target({TYPE,FIELD})
    @Documented
    public @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 using XStreamConverters or useImplicitType() == 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 
      Modifier and Type Required Element Description
      java.lang.Class<? extends ConverterMatcher> value  
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      boolean[] booleans  
      byte[] bytes  
      char[] chars  
      double[] doubles  
      float[] floats  
      int[] ints  
      long[] longs  
      java.lang.Class<?>[] nulls
      Provide null types as arguments for the converter's constructor arguments.
      int priority  
      short[] shorts  
      java.lang.String[] strings  
      java.lang.Class<?>[] types
      Provide class types as arguments for the converter's constructor arguments.
      boolean useImplicitType
      Flag to provide the current type as implicit first Class argument to a converter's constructor.
      • priority

        int priority
        Default:
        0
      • useImplicitType

        boolean useImplicitType
        Flag 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

        java.lang.Class<?>[] types
        Provide 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 setting useImplicitType() to false.

        Returns:
        the types
        Since:
        1.4.2
        Default:
        {}
      • strings

        java.lang.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

        java.lang.Class<?>[] nulls
        Provide null types as arguments for the converter's constructor arguments.
        Returns:
        the types provided as null values
        Since:
        1.4.9
        Default:
        {}