I am mostly interested in Java, but I think it\'s a general question. Recently I\'ve been working with Arquillian framework (ShrinkWrap) that uses a lot of meth
This pattern is useful when there is series of update needs to be done on the same object and the update operations don't need to return any status of updation. For example I used this pattern in some api I wrote for database layer. For fetching some rows based on many criteria many conditions needs to be added to where clause. Using this pattern the criteria can be added as follows.
CriteriaCollection().instance()
.addSelect(Criteria.equalTo(XyzCriteria.COLUMN_1, value1))
.addSelect(Criteria.equalTo(XyzCriteria.COLUMN_2, value2))
.addSelect(Criteria.isIn(XyzCriteria.COLUMN_3, values3))
.addOrder(OrderCriteria.desc(XyzCriteria.Order.COLUMN_1));
Ultimately it improves the readability of the code.