How do you query object collections in Java (Criteria/SQL-like)?

后端 未结 7 1435
醉话见心
醉话见心 2020-11-30 05:03

Suppose you have a collection of a few hundred in-memory objects and you need to query this List to return objects matching some SQL or Criteria like query. For example, you

7条回答
  •  时光说笑
    2020-11-30 05:16

    I would use a Comparator that takes a range of years and license plate pattern as input parameters. Then just iterate through your collection and copy the objects that match. You'd likely end up making a whole package of custom Comparators with this approach.

提交回复
热议问题