com.github.phantomthief.util.StackTraceProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of more-lambdas Show documentation
Show all versions of more-lambdas Show documentation
Some useful lambda implements for Java 8.
The newest version!
package com.github.phantomthief.util;
import java.util.function.Predicate;
import javax.annotation.Nullable;
import com.google.common.base.Predicates;
/**
* 调用栈提供器接口
* 用于获得当前调用点向上查找的调用栈位置,通常应用在需要获得方法调用位置的场景。默认包括JDK8/JDK9的两个实现,JDK9的实现更高效。
*
* @author w.vela
* Created on 2019-08-01.
*/
interface StackTraceProvider {
/**
* 返回 {@param locationAwareClassChecker} 最接近调用方方向第二个元素(跳过一个)
*/
@Nullable
StackTraceElement getCallerPlace(Predicate locationAwareClassChecker, Predicate ignore);
@Nullable
default StackTraceElement getCallerPlace(Class> locationAwareClassChecker) {
String name = locationAwareClassChecker.getName();
return getCallerPlace(name::equals, Predicates.alwaysFalse());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy