| /******************************************************************************* |
| * 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: |
| * Mathieu Larose (Savoir-faire Linux) - Initial API and implementation |
| * |
| * SPDX-License-Identifier: EPL-1.0 |
| * |
| *******************************************************************************/ |
| package org.eclipse.apogy.core.programs.javascript.ui.testers; |
| |
| import java.util.Collection; |
| import java.util.Iterator; |
| |
| import org.eclipse.apogy.core.programs.javascript.JavaScriptProgram; |
| import org.eclipse.core.expressions.PropertyTester; |
| |
| public class JavaScriptProgramTester extends PropertyTester { |
| |
| @Override |
| public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { |
| if (receiver instanceof Collection) { |
| @SuppressWarnings({ "rawtypes", "unchecked" }) |
| Iterator<Object> receiverCollection = ((Collection) receiver).iterator(); |
| while (receiverCollection.hasNext()) { |
| Object object = receiverCollection.next(); |
| if (object instanceof JavaScriptProgram) { |
| return true; |
| } |
| } |
| } |
| return receiver instanceof JavaScriptProgram; |
| } |
| |
| } |