0

I can't understand the following code:

final Specifications<PaymentBatch> criteriaSpecification = 
        where(paymentBatchesInZone(getCurrentZone()))
        .and(new PaymentBatchSearchFilter(paymentBatchSearchQueryDTO));

What do .and and where stand for?

falsarella
  • 12,217
  • 9
  • 69
  • 115
imran
  • 155
  • 1
  • 9
  • 1
    It's just a method on whatever class `where` returns. – blm Dec 12 '15 at 17:46
  • @blm Actually, what `and` returns... – falsarella Dec 12 '15 at 18:29
  • @falsarella The result of the entire expression is what `and` returns, `and` is a method on what `where` returns. I could have made my comment clearer, but that's what my comment means. – blm Dec 12 '15 at 22:59

1 Answers1

2

This is a pattern called fluent interface.

For details see here: Is it bad practice to make a setter return "this"?

Every call to a function returns the current object so subsequent method calls may be made without having a separate reference declared.

Thus both methods where() and and() are parts of a DAO pattern and provide the means to create an SQL WHERE statement.

Community
  • 1
  • 1
Marcinek
  • 2,144
  • 1
  • 19
  • 25