KinQ
LinQ for Java
What is LinQ ?
With LinQ you can easily filter Lists to your liking.
It's present in C# and uses the Lambda expression for filters.
This library requires Java Language Level 8
Example 1
You've got an array of Players and you want to get the username of everyone
Its pretty easy with KinQ
ArrayList<Player> myPlayerArray = new ArrayList<>();
KinQ kinQ = new KinQ(myPlayerArray);
Collection<String> usernames = kinQ.select("username").toList();
What did I do there ?
You have to create a new Instance of the "KinQ" class.
Pass your list in the constructor.
Then I used the "select(Fieldname)" method.
You only have to pass the fieldname.
You can also enter private fieldnames, Kinq will retrieve the value automatically.
Finally, toList converted everything to a list and returned it.
Example 2
You've got an array of Players and you want to get the players with more that 5 points.
Again its pretty easy with KinQ
ArrayList<Player> myPlayerArray = new ArrayList<>();
KinQ kinQ = new KinQ(myPlayerArray);
Collection<Player> playersWithMatchingScore = kinQ.where(Player.class, player -> player.getScore() > 5).toList();
What did I do there ?
You have to create a new Instance of the "KinQ" class.
Pass your list in the constructor.
Then I used the "where(Class type, Lambda Filter)"method.
You have to pass the filter in lambda expression. Optionally you can pass the type first. So the Lambda expression recognizes which object is being passed to it.
Finally, toList converted everything to a list and returned it.
You can combine these actions to your pleasure.
Please provide me feedback in the comments and tell me new feature ideas and maybe I'll implement them ;)
Similar projects
Plugin →Let Me Despawn
Improves performance by tweaking mob despawn rules. Say bye to pesky unintentional persistent mobs.
25MSueta
JourneyMap
Real-time map used for mapping in-game or your browser as you explore.
14.7MSueta
Emotecraft
Create your own emotes in Minecraft.
7.5MSueta
Simple Tpa
A simple tpa plugin which sends requests
5.4MSueta
Common Network
Forge and Fabric Unified Networking Solution
3.9MSueta
Set Home
A lightweight plugin for players to set their homes.
3.8MSueta