Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package DataAccess.Entity; import com.mongodb.BasicDBObject; import com.mongodb.DBObject; /** * * @author ace */ public class Restaurant { public Restaurant() { } public String name; public String address; public Integer phone; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public Integer getPhone() { return phone; } public void setPhone(Integer phone) { this.phone = phone; } public Restaurant(String nameRestaurant, String address, Integer phone) { this.name = nameRestaurant; this.address = address; this.phone = phone; } public Restaurant(BasicDBObject dBObjectRs) { this.name = dBObjectRs.getString("name"); this.address = dBObjectRs.getString("direccion"); this.phone = dBObjectRs.getInt("phone"); } public BasicDBObject toDBObjectRestaurant() { // Creamos una instancia BasicDBObject BasicDBObject dBObjectRs = new BasicDBObject(); dBObjectRs.append("name", this.getName()); dBObjectRs.append("direccion", this.getAddress()); dBObjectRs.append("phone", this.getPhone()); return dBObjectRs; } public DBObject toDBObjectRestaurant2(DBObject dboj) { name = dboj.toString(); // Creamos una instancia BasicDBObject BasicDBObject dBObjectRs = new BasicDBObject(); dBObjectRs.append("name", this.getName()); dBObjectRs.append("direccion", this.getAddress()); dBObjectRs.append("phone", this.getPhone()); return dBObjectRs; } }