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

edu.stanford.protege.webprotege.match.MatcherAdapter Maven / Gradle / Ivy

The newest version!
package edu.stanford.protege.webprotege.match;

import javax.annotation.Nonnull;

import static com.google.common.base.Preconditions.checkNotNull;

/**
 * Matthew Horridge
 * Stanford Center for Biomedical Informatics Research
 * 2019-12-02
 */
public class MatcherAdapter implements Matcher {

    @Nonnull
    private final Class targetCls;

    @Nonnull
    private final Matcher targetMatcher;

    public MatcherAdapter(@Nonnull Class targetCls,
                          @Nonnull Matcher targetMatcher) {
        this.targetCls = checkNotNull(targetCls);
        this.targetMatcher = checkNotNull(targetMatcher);
    }

    @Override
    public boolean matches(@Nonnull S value) {
        if(!targetCls.isInstance(value)) {
            return false;
        }
        else {
            T target = targetCls.cast(value);
            return targetMatcher.matches(target);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy