All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lordofthejars.nosqlunit.demo.couchdb.MapBookConverter Maven / Gradle / Ivy

There is a newer version: 1.0.0-rc.5
Show newest version
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;
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy