mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Added InstanceOfPredicate.
This commit is contained in:
parent
aae4792550
commit
c6557f0a86
1 changed files with 28 additions and 0 deletions
|
@ -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<T> implements IUnaryPredicate<T> {
|
||||||
|
private Class<T> type;
|
||||||
|
|
||||||
|
public InstanceOfPredicate(Class<T> type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(T obj) {
|
||||||
|
return type.isInstance(obj);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue