To convert class to map in Java you can use the ObjectMapper by the Jackson library. First declare the class model.
class MyClass {
public int myValue;
public String myUser;
}
And then do the convertion.
MyClass obj = new MyClass();
obj.myValue = 1;
ObjectMapper mapObject = new ObjectMapper();
Map <String, Object> mapObj = mapObject.convertValue(obj, Map.class);