diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/InstanceOfPredicate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/InstanceOfPredicate.java new file mode 100644 index 00000000000..bc5f5c99147 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/InstanceOfPredicate.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2014 Google, Inc and others. + * 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: + * Sergey Prigogin (Google) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.parser.util; + +/** + * Unary predicate returning {@code true} if the object is an instance of the given class. + * @since 5.7 + */ +public class InstanceOfPredicate implements IUnaryPredicate { + private Class type; + + public InstanceOfPredicate(Class type) { + this.type = type; + } + + @Override + public boolean apply(T obj) { + return type.isInstance(obj); + } +}