001/*
002 * Copyright c 2018 Rusi Popov, MDA Tools.net All rights reserved.
003 *
004 * This program and the accompanying materials are made available under the terms of the
005 * Eclipse Public License v2.0 which accompanies this distribution, and is available at
006 * http://www.eclipse.org/legal/epl-v20.html
007 */
008package net.mdatools.modelant.core.filter;
009
010import java.util.Collection;
011
012import net.mdatools.modelant.core.api.Filter;
013import net.mdatools.modelant.core.api.Selector;
014
015/**
016 * Compose a filter on a selector
017 * @author Rusi Popov (popovr@mdatools.net)
018 */
019public final class FilterSelect<A,T> implements Selector<A,T> {
020
021  private final Filter<T> f;
022  private final Selector<A, T> s;
023
024  public FilterSelect(Filter<T> f, Selector<A, T> s) {
025    this.f = f;
026    this.s = s;
027  }
028
029  /**
030   * @see net.mdatools.modelant.core.api.Function#execute(java.lang.Object)
031   */
032  public Collection<T> execute(A argument) throws RuntimeException, IllegalArgumentException {
033    return f.execute(s.execute(argument));
034  }
035}