// Path: src/main/java/shopJava/model/User.java
// public class User {
// 
//     private static final String ID = "_id";
//     private static final String NAME = "name";
//     private static final String PASSWORD = "password";
// 
//     public final String name;
//     public final String password;
// 
//     public User(final String name, final String password) {
//         this.name = name;
//         this.password = password;
//     }
// 
//     public User(Document doc) {
//         this(doc.getString(ID), doc.getString(PASSWORD));
//     }
// 
//     @Override
//     public String toString() {
//         return "User{" +
//                 NAME + "='" + name + '\'' +
//                 ", " + PASSWORD + "='" + password + '\'' +
//                 '}';
//     }
// 
//     public void print() {
//         System.out.print(this);
//     }
// 
//     public void println() {
//         System.out.println(this);
//     }
// 
//     public Document toDocument() {
//         return new Document(ID, name).append(PASSWORD, password);
//     }
// }
// 
// Path: src/main/java/shopJava/util/Util.java
// public static void sleep(final int seconds) {
//     try {
//         Thread.sleep(seconds * 1000L);
//     } catch (InterruptedException e) {
//         e.printStackTrace();
//     }
// }


import com.mongodb.async.SingleResultCallback;
import com.mongodb.async.client.MongoClient;
import com.mongodb.async.client.MongoClients;
import com.mongodb.async.client.MongoCollection;
import com.mongodb.async.client.MongoDatabase;
import org.bson.Document;
import shopJava.model.User;
import java.util.ArrayList;
import java.util.List;
import static shopJava.util.Constants.MONGODB_URI;
import static shopJava.util.Constants.SHOP_DB_NAME;
import static shopJava.util.Constants.USERS_COLLECTION_NAME;
import static shopJava.util.Util.sleep;
package shopJava.async_reactive;




@SuppressWarnings("Convert2MethodRef")
public class Callback {

    public static void main(String[] args) {
        new Callback();
    }

    private final MongoClient client = MongoClients.create(MONGODB_URI);
    private final MongoDatabase db = client.getDatabase(SHOP_DB_NAME);
    private final MongoCollection<Document> usersCollection = db.getCollection(USERS_COLLECTION_NAME);

    private Callback() {

        SingleResultCallback<List<String>> callback = new SingleResultCallback<List<String>>() {
            @Override
            public void onResult(List<String> simpsons, Throwable t) {
                if (t != null) {
                    t.printStackTrace();
                } else {
                    simpsons.forEach(simpson -> System.out.println(simpson));
                }
            }
        };

        nonblockingIOWithCallbacks_GetDataFromDB(callback);

// Path: src/main/java/shopJava/model/User.java
// public class User {
// 
//     private static final String ID = "_id";
//     private static final String NAME = "name";
//     private static final String PASSWORD = "password";
// 
//     public final String name;
//     public final String password;
// 
//     public User(final String name, final String password) {
//         this.name = name;
//         this.password = password;
//     }
// 
//     public User(Document doc) {
//         this(doc.getString(ID), doc.getString(PASSWORD));
//     }
// 
//     @Override
//     public String toString() {
//         return "User{" +
//                 NAME + "='" + name + '\'' +
//                 ", " + PASSWORD + "='" + password + '\'' +
//                 '}';
//     }
// 
//     public void print() {
//         System.out.print(this);
//     }
// 
//     public void println() {
//         System.out.println(this);
//     }
// 
//     public Document toDocument() {
//         return new Document(ID, name).append(PASSWORD, password);
//     }
// }
// 
// Path: src/main/java/shopJava/util/Util.java
// public static void sleep(final int seconds) {
//     try {
//         Thread.sleep(seconds * 1000L);
//     } catch (InterruptedException e) {
//         e.printStackTrace();
//     }
// }


// Path: src/main/java/shopJava/async_reactive/Callback.java
import com.mongodb.async.SingleResultCallback;
import com.mongodb.async.client.MongoClient;
import com.mongodb.async.client.MongoClients;
import com.mongodb.async.client.MongoCollection;
import com.mongodb.async.client.MongoDatabase;
import org.bson.Document;
import shopJava.model.User;
import java.util.ArrayList;
import java.util.List;
import static shopJava.util.Constants.MONGODB_URI;
import static shopJava.util.Constants.SHOP_DB_NAME;
import static shopJava.util.Constants.USERS_COLLECTION_NAME;
import static shopJava.util.Util.sleep;

package shopJava.async_reactive;




@SuppressWarnings("Convert2MethodRef")
public class Callback {

    public static void main(String[] args) {
        new Callback();
    }

    private final MongoClient client = MongoClients.create(MONGODB_URI);
    private final MongoDatabase db = client.getDatabase(SHOP_DB_NAME);
    private final MongoCollection<Document> usersCollection = db.getCollection(USERS_COLLECTION_NAME);

    private Callback() {

        SingleResultCallback<List<String>> callback = new SingleResultCallback<List<String>>() {
            @Override
            public void onResult(List<String> simpsons, Throwable t) {
                if (t != null) {
                    t.printStackTrace();
                } else {
                    simpsons.forEach(simpson -> System.out.println(simpson));
                }
            }
        };

        nonblockingIOWithCallbacks_GetDataFromDB(callback);

        sleep(2);