Skip to main content
summaryrefslogtreecommitdiffstats
blob: 9a5fc115337f6e948746c09d2f92b9653b9a48ce (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*******************************************************************************
 * Copyright (c) 2011 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.display.presenter.internal;

import java.util.Collection;
import org.eclipse.osee.display.presenter.ArtifactFilter;
import org.eclipse.osee.executor.admin.CancellableCallable;
import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.jdk.core.util.Filter;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeReadable;
import org.eclipse.osee.orcs.search.Match;

/**
 * @author Roberto E. Escobar
 */
public class FilteredMatchCallable extends CancellableCallable<Collection<Match<ArtifactReadable, AttributeReadable<?>>>> implements Filter<Match<ArtifactReadable, AttributeReadable<?>>> {

   private final Collection<Match<ArtifactReadable, AttributeReadable<?>>> toSanitize;
   private final ArtifactFilter sanitizer;

   public FilteredMatchCallable(ArtifactFilter sanitizer, Collection<Match<ArtifactReadable, AttributeReadable<?>>> toSanitize) {
      this.sanitizer = sanitizer;
      this.toSanitize = toSanitize;
   }

   @Override
   public Collection<Match<ArtifactReadable, AttributeReadable<?>>> call() throws Exception {
      Collections.filter(toSanitize, this);
      return toSanitize;
   }

   @Override
   public boolean accept(Match<ArtifactReadable, AttributeReadable<?>> item) throws Exception {
      checkForCancelled();
      return sanitizer.accept(item.getItem());
   }
}

Back to the top