// Path: jbbvm/bbvm-core/src/main/java/me/wener/bbvm/exception/ResourceMissingException.java
// public class ResourceMissingException extends ExecutionException {
//     private String type;
//     private int handler;
// 
//     public ResourceMissingException(String message, String type, int handler) {
//         super(message);
//         this.type = type;
//         this.handler = handler;
//     }
// 
//     public ResourceMissingException(String type, int handler) {
//         this.type = type;
//         this.handler = handler;
//     }
// 
//     @Override
//     public String toString() {
//         return MoreObjects.toStringHelper(this)
//             .add("type", type)
//             .add("handler", handler)
//             .add("message", getMessage())
//             .toString();
//     }
// }


import com.google.common.base.Throwables;
import me.wener.bbvm.exception.ResourceMissingException;
package me.wener.bbvm.dev;


/**
 * @author wener
 * @since 15/12/13
 */
public interface ResourceManager<M extends ResourceManager, R extends Resource> {
    R getResource(int handler) throws ResourceMissingException;

    /**
     * Close this resource, if the resource is not exists may not throw an exception
     */
    default R close(int handler) {
        try {
            R resource = getResource(handler);
            resource.close();
// Path: jbbvm/bbvm-core/src/main/java/me/wener/bbvm/exception/ResourceMissingException.java
// public class ResourceMissingException extends ExecutionException {
//     private String type;
//     private int handler;
// 
//     public ResourceMissingException(String message, String type, int handler) {
//         super(message);
//         this.type = type;
//         this.handler = handler;
//     }
// 
//     public ResourceMissingException(String type, int handler) {
//         this.type = type;
//         this.handler = handler;
//     }
// 
//     @Override
//     public String toString() {
//         return MoreObjects.toStringHelper(this)
//             .add("type", type)
//             .add("handler", handler)
//             .add("message", getMessage())
//             .toString();
//     }
// }


// Path: jbbvm/bbvm-core/src/main/java/me/wener/bbvm/dev/ResourceManager.java
import com.google.common.base.Throwables;
import me.wener.bbvm.exception.ResourceMissingException;

package me.wener.bbvm.dev;


/**
 * @author wener
 * @since 15/12/13
 */
public interface ResourceManager<M extends ResourceManager, R extends Resource> {
    R getResource(int handler) throws ResourceMissingException;

    /**
     * Close this resource, if the resource is not exists may not throw an exception
     */
    default R close(int handler) {
        try {
            R resource = getResource(handler);
            resource.close();
        } catch (ResourceMissingException e) {