package com.capgemini.framework.teamcenter.resolution.filtering;

import java.util.Arrays;

/** Exclude objects according to their type. */
public class TcTypeExclusionFilter implements ITcTypeFilter {

    private final String[] forbidden;

    /**
     * Builds a {@link ITcTypeFilter} that will exclude any object of the provided type.
     * 
     * @param forbidden the object types to be excluded
     */
    public TcTypeExclusionFilter(final String... forbidden) {
        this.forbidden = forbidden;
        Arrays.sort(forbidden);
    }

    @Override
    public boolean isExcluded(final String type) {
        return Arrays.binarySearch(forbidden, type) >= 0;
    }

    @Override
    public boolean isIncluded(final String type) {
        return !isExcluded(type);
    }

}
