com.lordofthejars.nosqlunit.demo.custom.MapBookConverter Maven / Gradle / Ivy
package com.lordofthejars.nosqlunit.demo.custom;
import java.util.HashMap;
import java.util.Map;
import com.lordofthejars.nosqlunit.demo.model.Book;
public class MapBookConverter {
private static final String TITLE = "title";
private static final String NUMBER_OF_PAGES = "numberOfPages";
public static Book toBook(Map book) {
return new Book((String)book.get(TITLE), (Integer) book.get(NUMBER_OF_PAGES));
}
public static Map toMap(Book book) {
Map map = new HashMap();
map.put(TITLE, book.getTitle());
map.put(NUMBER_OF_PAGES, Integer.toString(book.getNumberOfPages()));
return map;
}
}