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

org.anarres.graphviz.builder.GraphVizScopePredicate Maven / Gradle / Ivy

There is a newer version: 1.0.12
Show newest version
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.anarres.graphviz.builder;

import com.google.common.base.Predicate;
import javax.annotation.Nonnull;

/**
 *
 * @author shevek
 */
public abstract class GraphVizScopePredicate implements Predicate {

    @Nonnull
    public static GraphVizScopePredicate all() {
        return new GraphVizScopePredicate() {
            @Override
            public boolean apply(GraphVizScope t) {
                return true;
            }
        };
    }

    @Nonnull
    public static GraphVizScopePredicate include(final Class... types) {
        return new GraphVizScopePredicate() {
            @Override
            public boolean apply(GraphVizScope t) {
                for (Class type : types)
                    if (type.isInstance(t))
                        return true;
                return false;
            }
        };
    }

    @Nonnull
    public static GraphVizScopePredicate exclude(final Class... types) {
        return new GraphVizScopePredicate() {
            @Override
            public boolean apply(GraphVizScope t) {
                for (Class type : types)
                    if (type.isInstance(t))
                        return false;
                return true;
            }
        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy