Skip to content

Allow to use any object as a choice #44

@Bastian

Description

@Bastian

First of all, thank you for this great library.
However, there's a small issue I have with it: For one of my projects I'm implementing a search for JavaDoc methods and have a class JavadocMethod with methods like getMethodName(), getClassName() and getUrl().
For searching it would be very convenient to just use the object itself for search, so I can access the url of the found method.
I'm thinking about a generic solution like this:

public static <T> List<ExtractedResult<T>> extractTop(String query, Collection<T> choices, Function<T, String> mapper, int limit)

which allows to use any object by just providing a function which maps this object to a string.

Collection<JavadocMethod> methods = ...;
FuzzySearch.extractTop("String#valeuOf(loong)", methods, method -> String.format("%s#%s", method.getClassName(), method.getMethodName()), 5);

Can you imagine implementing such a feature or accept a pull requests that adds it?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions