blob: a6138cfcb0f0a35745b1347c145fa583132e5738 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency
* 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:
* Pierre Allard,
* Regent L'Archeveque,
* Olivier L. Larouche - initial API and implementation
* SPDX-License-Identifier: EPL-1.0
*
*******************************************************************************/
package org.eclipse.apogy.common.emf.impl;
import java.util.Iterator;
import org.eclipse.apogy.common.emf.CompositeFilterType;
import org.eclipse.apogy.common.emf.IFilter;
public class CompositeFilterCustomImpl<T> extends CompositeFilterImpl<T> {
@Override
public boolean matches(T object) {
boolean matches = false;
if (getFilters().size() == 0)
return true;
switch (getFilterChainType().getValue()) {
case CompositeFilterType.AND_VALUE: {
Iterator<IFilter<T>> it = getFilters().iterator();
matches = true;
while (it.hasNext() && matches) {
matches = it.next().matches(object);
}
}
break;
case CompositeFilterType.OR_VALUE: {
Iterator<IFilter<T>> it = getFilters().iterator();
matches = false;
while (it.hasNext() && !matches) {
matches = it.next().matches(object);
}
}
break;
default:
break;
}
return matches;
}
} // CompositeFilterImpl