com.lordofthejars.nosqlunit.demo.couchdb.MapBookConverter Maven / Gradle / Ivy
package com.lordofthejars.nosqlunit.demo.couchdb;
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.parseInt((String) 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;
}
}