Package de.bananaco.permissions.handlers

Source Code of de.bananaco.permissions.handlers.MySQLPackageManager

package de.bananaco.permissions.handlers;

import de.bananaco.permissions.mysql.MySQLHandler;
import de.bananaco.permissions.ppackage.PPackage;

import java.util.HashMap;
import java.util.Map;

public class MySQLPackageManager implements PackageManager {

    private final MySQLHandler handler;
    private final Map<String, PPackage> cache = new HashMap<String, PPackage>();

    public MySQLPackageManager(MySQLHandler handler) {
        this.handler = handler;
    }

    public PPackage getPackage(String p) {
        if (cache.containsKey(p)) {
            return cache.get(p);
        }
        PPackage pack = handler.getPPackage(p);
        if (pack != null) {
            cache.put(p, pack);
            return cache.get(p);
        } else {
            return null;
        }
    }

    public void addPackage(String p, String perm) {
        handler.addEntry(p, perm);
    }

}
TOP

Related Classes of de.bananaco.permissions.handlers.MySQLPackageManager

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.