001/* 002 * (C) Copyright 2017 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Ronan DANIELLOU 018 */ 019package org.nuxeo.targetplatforms.api.impl; 020 021import java.util.Collection; 022import java.util.HashSet; 023import java.util.Set; 024 025import org.nuxeo.targetplatforms.api.TargetInfo; 026import org.nuxeo.targetplatforms.api.TargetPlatformFilter; 027 028/** 029 * This filter accepts input data that is accepted by at least one of its filters. 030 * 031 * @since 1.0.74, 1.11.6033 032 */ 033public class TargetPlatformOrFilterImpl implements TargetPlatformFilter { 034 035 private static final long serialVersionUID = 1L; 036 037 Set<TargetPlatformFilter> filters; 038 039 public TargetPlatformOrFilterImpl() { 040 this(null); 041 } 042 043 public TargetPlatformOrFilterImpl(Collection<TargetPlatformFilter> filters) { 044 this.filters = new HashSet<TargetPlatformFilter>(); 045 if (filters != null) { 046 this.filters.addAll(filters); 047 } 048 } 049 050 public void addFilter(TargetPlatformFilter filter) { 051 filters.add(filter); 052 } 053 054 @Override 055 public boolean accepts(TargetInfo t) { 056 for (TargetPlatformFilter filter : filters) { 057 if (filter.accepts(t)) { 058 return true; 059 } 060 } 061 return false; 062 } 063 064}