GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - alansferreira/coollection: A cool way to manipulate collections in Java.

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

73 Commits
73 Commits

Folders and files

NameName
Last commit message
Last commit date
coollection
coollection
 
 
.project
.project
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
README.textile
README.textile
 
 

Repository files navigation

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":http://github.com/downloads/wagnerandrade/coollection/coollection-0.2.0.jar

How it works?

It's easy to use. Just import the collection static methods in your class and... More nothing!

import static org.simple.coollection.Coollection.*;

How to use this?

public class Animal {
  private String name;
  private Specime specime;
  
}

List<Animal> animals;
  

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();

5 - Select

Select field from expression.

from(animals).select("name").all();
from(animals).select("toString").all();
from(animals).select("specime").all();
from(animals).<Specime>select("specime").all();

You can use just order, without filter.

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

To Maven Integration

import project from git to your workspace and add dependency

  <dependency>
    <groupId>coollection</groupId>
    <artifactId>coollection</artifactId>
    <version>1.0.0-MASTER</version>
  </dependency>

Be happy!

About

A cool way to manipulate collections in Java.

wagnerandrade.com

Resources

Readme
License
Activity

Stars

2 stars

Watchers

2 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.