All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.rocketmq.shade.ch.qos.logback.core.model.processor.ChainedModelFilter Maven / Gradle / Ivy

package org.apache.rocketmq.shade.ch.qos.logback.core.model.processor;

import java.util.ArrayList;
import java.util.List;

import org.apache.rocketmq.shade.ch.qos.logback.core.model.Model;
import org.apache.rocketmq.shade.ch.qos.logback.core.spi.FilterReply;

public class ChainedModelFilter implements ModelFilter {

    List modelFilters = new ArrayList<>();

    public ChainedModelFilter() {
    }

    static public ChainedModelFilter newInstance() {
        return new ChainedModelFilter();
    }

    public ChainedModelFilter allow(Class allowedType) {
        modelFilters.add(new AllowModelFilter(allowedType));
        return this;
    }

    public ChainedModelFilter deny(Class allowedType) {
        modelFilters.add(new DenyModelFilter(allowedType));
        return this;
    }

    public ChainedModelFilter denyAll() {
        modelFilters.add(new DenyAllModelFilter());
        return this;
    }

    public ChainedModelFilter allowAll() {
        modelFilters.add(new AllowAllModelFilter());
        return this;
    }

    @Override
    public FilterReply decide(Model model) {

        for (ModelFilter modelFilter : modelFilters) {
            FilterReply reply = modelFilter.decide(model);

            switch (reply) {
            case ACCEPT:
            case DENY:
                return reply;
            case NEUTRAL:
                // next
            }
        }
        return FilterReply.NEUTRAL;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy