Java Lambda使用记录
lambda与匿名函数的区别
使用案例
1
定义接口
/**
* Strategy interface to filter {@link Entry Entries}.
*/
@FunctionalInterface
interface EntryFilter {
/**
* Apply the jar entry filter.
* @param entry the entry to filter
* @return {@code true} if the filter matches
*/
boolean matches(Entry entry);
}
使用
static final EntryFilter NESTED_ARCHIVE_ENTRY_FILTER = (entry) -> {
if (entry.isDirectory()) {
return entry.getName().equals("BOOT-INF/classes/");
}
return entry.getName().startsWith("BOOT-INF/lib/");
};
protected boolean isNestedArchive(Archive.Entry entry) {
return NESTED_ARCHIVE_ENTRY_FILTER.matches(entry);
}
来源:Spring Boot Loader: org.springframework.boot.loader.JarLauncher