just open source is a fully tested Java tool class. The current code has undergone a complete test and is applying to the MAVEN central repository.
The address is as follows:
Https://github.com/Jimmy-Shi/bean-query
instructions for use are as follows:
Bean-query
Click here for 中文版 version.
Beanquery is a Java tool library that converts objects to maps. Supports selecting some attributes in the bean, sorting the results, and querying by criteria. It can be used not only for top-level objects, but also for child objects.
The use of beanquery is very simple and straightforward, and the example code is as follows:
/static import Beanqueryimport static cn.jimmyshi.beanquery.beanquery.*;//use Select, from, where, order BY, DESC, and ASC to assemble a query, Then execute the Execute method to get the result. list<map<string, object>> result = Select ("Price,name,mainauthor.name as Mainauthorname") . From ( bookcollection) . Where ( //for books name is Book2 or starts with Book1 anyOf ( value ("Name", StartsWith ( "Book1"), value ("Name", Is ("Book2"))) , //for books price between (53,65) AllOf ( value ("Price") , GreaterThan (53d)), value ("Price", LessThan (65d))). ("name"). Desc () . Execute ();
in the example above, the contents of Bookcollection are as follows (in JSON format)
[{"Price": 55.55, "name": "Book1", "Mainauthor": {"name": "Book1-mainauthor", "address": {"Addre SS ":" Shenzhen Guangdong China "," postcode ":" 518000 "}," BirthDate ":" 1982-01-30t14:52:39 "}}, {" Price ": 52.55," name ":" Book12 "," Mainauthor ": {" name ":" Book1-mainauthor "," address ": {" Address ":" She Nzhen Guangdong China "," postcode ":" 518000 "}," BirthDate ":" 1982-01-30t14:52:39 "}}, {" Price ": 5 3.55, "name": "Book13", "Mainauthor": {"name": "Book13-mainauthor", "address": {"Address": "Shenzhen G Uangdong China "," postcode ":" 518000 "}," BirthDate ":" 1982-01-30t14:52:39 "}}, {" Price ": 60.0, "Name": "Book14", "Mainauthor": {"name": "Book14-mainauthor", "address": {"Address": "Shenzhen Guangdong China "," postcode ":" 518000 "}," BirthDate ":" 1982-01-30t14:52:39 "}}, {" Price ": 50.55," name " : "Book15", "MainauthoR ": {" name ":" Book1-mainauthor "," address ": {" Address ":" Shenzhen Guangdong China "," postcode ":" 5180 XX "}," BirthDate ":" 1982-01-30t14:52:39 "}}, {" Price ": 77.77," name ":" Book3 "," Mainauthor ": { "Name": "Book3-mainauthor", "address": {"Address": "Shenzhen Guangdong China", "postcode": "518005" }, "BirthDate": "1982-01-30t14:52:39"}}, {"Price": 66.66, "name": "Book2", "Mainauthor": {"name" : "Book2-mainauthor", "address": {"Address": "Shenzhen Guangdong China", "postcode": "518005"}, "BirthDate": "1982-01-30t14:52:39"}}]
after execution, the contents of result are as follows (in JSON format)
[ { "price": 60.0, "name": "Book14", "Mainauthorname": "Book14-mainauthor" }, { " Price ": 53.55, " name ":" Book13 ", " Mainauthorname ":" Book13-mainauthor " }, { " price ": 55.55, "name": "Book1", " mainauthorname": "Book1-mainauthor" }]
Bean-query A Java tool library that converts objects to maps