package de.tud.kom.p2psim.impl.common;

import de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor;

/**
 * Created by Clemens on 29.04.2017.
 */
public class PackageFilter
{
    private String packageName;
    private TYPE type;

    @XMLConfigurableConstructor({"packageName", "type"})
        public PackageFilter(String packageName, String type)
        {
            this.packageName = packageName;
            this.type = TYPE.valueOf(type.toUpperCase());
        }

    private String getPackageName()
    {
        return packageName;
    }

    public boolean isWhitelist()
    {
        return type == TYPE.INCLUDE;
    }


    public boolean subPackageOf(PackageFilter filter)
    {
        return filter.getPackageName().contains(packageName);
    }

    public boolean containsClass(Class c)
    {
        return c.getName().contains(packageName);
    }

    public enum TYPE
    {
        INCLUDE,

        EXCLUDE

        }
}
