Skip to content

Instantly share code, notes, and snippets.

@marchof
Last active September 28, 2017 22:18
Show Gist options
  • Save marchof/2ef153ad02b208c398a928808539eb0d to your computer and use it in GitHub Desktop.
Save marchof/2ef153ad02b208c398a928808539eb0d to your computer and use it in GitHub Desktop.
Alternative implementation for class Filters
/*******************************************************************************
* Copyright (c) 2009, 2017 Mountainminds GmbH & Co. KG and Contributors
* 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:
* Evgeny Mandrikov - initial API and implementation
*
*******************************************************************************/
package org.jacoco.core.internal.analysis.filter;
import org.objectweb.asm.tree.MethodNode;
/**
* Predefined filter sets.
*/
public final class Filters {
/**
* No filtering at all.
*/
public static final IFilter NONE = combine();
/**
* All available filters.
*/
public static final IFilter ALL = combine(new EnumFilter(),
new SyntheticFilter(), new SynchronizedFilter(),
new TryWithResourcesJavacFilter(), new TryWithResourcesEcjFilter(),
new PrivateEmptyNoArgConstructorFilter(),
new StringSwitchJavacFilter(), new LombokGeneratedFilter());
private static IFilter combine(final IFilter... filters) {
return new IFilter() {
public void filter(final String className,
final String superClassName, final MethodNode methodNode,
final IFilterOutput output) {
for (final IFilter filter : filters) {
filter.filter(className, superClassName, methodNode,
output);
}
}
};
}
private Filters() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment