"custom converter in xstream" Code Answer


here is the converter you need:

public class detaildollarsconverter extends reflectionconverter {

public detaildollarsconverter(mapper mapper,
        reflectionprovider reflectionprovider) {
    super(mapper, reflectionprovider);

public void marshal(object obj, hierarchicalstreamwriter writer,
        marshallingcontext context) {

    detaildollars dl = (detaildollars) obj;

    writer.setvalue(double.tostring(dl.getnode1() / dl.getnode2()));

public object unmarshal(hierarchicalstreamreader reader,
        unmarshallingcontext context) {
    return super.unmarshal(reader,context);

public boolean canconvert(class clazz) {
    return clazz.equals(detaildollars.class);


By AbraCadaver on June 7 2022

Answers related to “custom converter in xstream”

Only authorized users can answer the Search term. Please sign in first, or register a free account.