package com.sourcefellows.patterns.adapter;

import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.Marshaller;

import java.io.ByteArrayOutputStream;
import java.util.HashMap;

public class Main {

    public static void main(String[] args) throws Exception {

        Foo f = new Foo();
        f.hashmap = new HashMap<>();
        f.hashmap.put(1, "Test 1");
        f.hashmap.put(2, "Test 2");

        JAXBContext jaxbContext = JAXBContext.newInstance(Foo.class, MyHashMapEntryType.class, MyHashMapType.class);

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        marshaller.marshal(f, bos);

        System.out.println(bos.toString());

    }

}

