Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow to use any object as a choice #44

Closed
Bastian opened this issue Aug 4, 2018 · 4 comments
Closed

Allow to use any object as a choice #44

Bastian opened this issue Aug 4, 2018 · 4 comments

Comments

@Bastian
Copy link

Bastian commented Aug 4, 2018

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?

@xdrop
Copy link
Owner

xdrop commented Aug 4, 2018

Hey, thanks I like your suggestion!

Ideally we implement this through additional overloads so as to not break the existing API. I'd be very grateful for a PR otherwise, I'll try and get the time to work on it (which may be a while)

@Bastian
Copy link
Author

Bastian commented Aug 4, 2018

I'm glad you like it.

I'll try to create a PR when I find time for it.

@Bastian
Copy link
Author

Bastian commented Sep 20, 2018

Sorry, but I don't know if I have time for this anytime soon.

@xdrop
Copy link
Owner

xdrop commented Oct 29, 2018

Closed in #46.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants