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

com.github.dreamhead.moco.MocoMount Maven / Gradle / Ivy

Go to download

Moco is an easy setup stub framework, mainly focusing on testing and integration.

There is a newer version: 1.5.0
Show newest version
package com.github.dreamhead.moco;

import com.github.dreamhead.moco.mount.MountPredicate;
import com.github.dreamhead.moco.mount.MountTo;

import static com.github.dreamhead.moco.util.Preconditions.checkNotNullOrEmpty;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.apache.commons.io.FilenameUtils.wildcardMatch;

public final class MocoMount {
    public static MountTo to(final String target) {
        return new MountTo(checkNotNullOrEmpty(target, "Target should not be null"));
    }

    public static MountPredicate include(final String wildcard) {
        checkNotNullOrEmpty(wildcard, "Wildcard should not be null");
        return new MountPredicate() {
            @Override
            public boolean apply(final String filename) {
                return wildcardMatch(filename, wildcard);
            }
        };
    }

    public static MountPredicate exclude(final String wildcard) {
        return not(include(checkNotNullOrEmpty(wildcard, "Wildcard should not be null")));
    }

    private static MountPredicate not(final MountPredicate predicate) {
        checkNotNull(predicate);
        return new MountPredicate() {
            @Override
            public boolean apply(final String filename) {
                return !predicate.apply(filename);
            }
        };
    }

    private MocoMount() {
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy