Giter Club home page Giter Club logo

coollection's Introduction

Coollection

A cool way to manipulate collections in Java.

Iterate over a collection is a medieval way to filtering, mapping and ordering. And with Java we are used to work like that. Coollection changes that, is the future, while closures don’t arrives for Java.

Download Coollection 0.2.0

How it works?

It’s easy to use. Just add import static com.wagnerandade.coollection.Coollection.*; in your class and… More nothing!

How to use this?

1 – Filter

First you need a Collection. Here we create a Animal List, and we called it animals.

List<Animal> animals;

Later you goes add a lot of animals in this list.

Now, you want to take all cats, it’s easy for Coollections! In this case, name is a method (animal.name()).

from(animals).where("name", eq("Cat")).all();

Or, would the first animal with 2 year old? Easy too!

from(animals).where("age", eq(2)).first();

2 – Filter specification

You can be more specific in your query, adding more specifications, like and and or.

from(animals).where("name", eq("Lion")).and("age", eq(2)).all();
from(animals).where("name", eq("Dog")).or("age", eq(5)).all();

3 – Matchers

There are other matchers to be precise!

eq("Cat")
eqIgnoreCase("Cat")
contains("og")
greaterThan(3)
lessThan(10)
isNull()

Or a special matcher, called not.

not(eq("Bird"))
not(contains("at"))
not(isNull())

4 – Order

Order is a very interesting feature to sort your collection.

from(animals).where("name", eq("Cat")).orderBy("age").all();
from(animals).where("age", eq(5)).orderBy("name", Order.DESC).first();

You can use just order, without filter.

from(animals).orderBy("name");

Be happy!

coollection's People

Contributors

19was85 avatar danieltamiosso avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.