fellix / collect4j
- Source
- Commits
- Network (1)
- Issues (3)
- Downloads (0)
- Wiki (1)
- Graphs
-
Tree:
6eb723a
commit 6eb723a2fedc5b3ad49af43e9c6660e609c32e55
tree b348dad07d93ef8a9b4e39fad74dafdd1c148803
parent e36256c9e2f21c673c449d3877950bd0c8040c4d
tree b348dad07d93ef8a9b4e39fad74dafdd1c148803
parent e36256c9e2f21c673c449d3877950bd0c8040c4d
| name | age | message | |
|---|---|---|---|
| |
.classpath | ||
| |
.gitignore | ||
| |
.project | ||
| |
.settings/ | ||
| |
CONTRIBUTORS | ||
| |
MIT-LICENSE | ||
| |
README.markdown | ||
| |
pom.xml | ||
| |
src/ |
README.markdown
Collect4j
Collect4j is an DSL (Domain Specific Language) for manipulates Java Collections API. Simple Commands do filter and access values in a collection.
Using
Add the jar file collect4j-X.X.jar to your classpath, or dowload from maven repositories (repo1)
Supports
- eql for equals comparision
- like for string content
- supports generics (objects is supported too)
- comparates some fields (Only for your custom class)
TODO
- Implements more Collection searchs
- Map and Set Implementations
Usage Samples
- Simple Collections
List list = new ArrayList(); list.add("Uva"); list.add("Maça"); list.add("Melancia"); list.add("Melão"); list.add("Maracujá"); Collection busca = (Collection) new Collect().in(lista).when().like("Mel", "Ma"); //Search in the collection when the content contatis the passed string.
Generics Collections
public class Person{
String name;
int age;
public Person() {
super();
}
public Person(String name, int age) {
super();
this.name = name;
this.age = age;
}
//Getters and setters
/**
* Some cases the to string is used too
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "Person["+name+", "+age+" ]";
}
}
List<Person> persons = new ArrayList<Person>();
persons.add(new Person("Rafael", 21));
persons.add(new Person("Suélen", 19));
persons.add(new Person("Pedro", 23));
persons.add(new Person("Rodrigo", 23));
Collection<Person> busca = (Collection<Person>) new Collect().in(persons).when("age").eql("23");//Compare with the field age is equals to 23, and return a new collection
Collection<Person> busca = (Collection<Person>) new Collect().in(persons).when().eql("23");//Compare the Person#toString() contais the string "23"

