// Path: app/models/Setting.java
// public abstract class Setting {
//     @MongoId
//     protected String id;
// 
//     public String getId() {
//         return id;
//     }
// 
//     public void setId(String id) {
//         this.id = id;
//     }
// }


import models.Setting;
import org.jongo.MongoCollection;
import uk.co.panaxiom.playjongo.PlayJongo;
import javax.inject.Inject;
import javax.inject.Singleton;
package repositories;



@Singleton
public class SettingRepository {

    private MongoCollection collection;

    @Inject
    public SettingRepository(PlayJongo playJongo) {
        this.collection = playJongo.jongo().getCollection("setting");
    }

    public <T> T findById(Class<T> clazz) {
        return collection.findOne("{_id:#}", clazz.getSimpleName()).as(clazz);
//        return setting != null ? (T) setting.getValue() : null;
    }

    public void save(Setting u){
        u.setId(u.getClass().getSimpleName());
// Path: app/models/Setting.java
// public abstract class Setting {
//     @MongoId
//     protected String id;
// 
//     public String getId() {
//         return id;
//     }
// 
//     public void setId(String id) {
//         this.id = id;
//     }
// }


// Path: app/repositories/SettingRepository.java
import models.Setting;
import org.jongo.MongoCollection;
import uk.co.panaxiom.playjongo.PlayJongo;
import javax.inject.Inject;
import javax.inject.Singleton;

package repositories;



@Singleton
public class SettingRepository {

    private MongoCollection collection;

    @Inject
    public SettingRepository(PlayJongo playJongo) {
        this.collection = playJongo.jongo().getCollection("setting");
    }

    public <T> T findById(Class<T> clazz) {
        return collection.findOne("{_id:#}", clazz.getSimpleName()).as(clazz);
//        return setting != null ? (T) setting.getValue() : null;
    }

    public void save(Setting u){
        u.setId(u.getClass().getSimpleName());
        collection.save(u);