Is there a way to check if a commited file is tracked in LFS

Is there a way to use the java api to check if a commited file is tracked in LFS?

I am building a pre-hook and at some point I need to know if a change is tracked in LFS or not.
I have tried GitCommandBuilderFactory and it’s not working, I believe because LFS is an extension.

I’ve also tried running git cat-file to check if the change is an LFS pointer, but this check has quite a lot of edge cases that can cause command exceptions and delays.

Is there some efficient way to use PluginCommandBuilderFactory or something similar, to tell if the file in a change is tracked in LFS?