Skip to content

fellix/collect4j

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

Building from source

Needs:

  • Sun SDK for Java 1.6
  • Apache Maven 2.0.8
Clone this repository Execute a comand mvn clean install

Supports

  • eql for equals comparision
  • like for string content
  • only method, is same on eql but if eql receive two values is used or, only use and
  • supports generic (objects is supported too)
  • comparates some fields (Only for your custom class)

TODO

  • Implements more Collection search (Like a regex)
  • Map 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 persons = new ArrayList();
		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 busca = (Collection) new Collect().in(persons).when("age").eql(23);//Compare with the field age is equals to 23, and return a new collection
	  Collection busca = (Collection) new Collect().in(persons).when().eql("23");//Compare the Person#toString() contais the string "23"

About

DSL for manipulate java collections

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages