RequestContext helper methods to simplify request type check

Description

in RH we have a lot of code as follows:

1 2 3 4 5 6 7 8 9 10 11 12 if ( // PUT|PATCH /db/coll/docid (context.getType() == TYPE.DOCUMENT && (context.getMethod() == RequestContext.METHOD.PATCH || context.getMethod() == RequestContext.METHOD.PUT)) // POST /db/coll { <doc> } and POST /db/coll [ { <doc> }, { <doc> } ] || ((context.getType() == TYPE.COLLECTION) && (context.getMethod() == RequestContext.METHOD.POST)) // PATCH /db/coll/* || ((context.getType() == TYPE.BULK_DOCUMENTS) && context.getMethod() == RequestContext.METHOD.PATCH)) { // do something }

we need to simplify as follows

1 2 3 4 5 6 7 return ( // PUT|PATCH /db/coll/docid (context.isDocument() && (context.isPatch() || context.isPut()) // POST /db/coll { <doc> } and POST /db/coll [ { <doc> }, { <doc> } ] || (context.isCollection() && (context.isPost()) || ((context.isBulkDocuments() && context.getMethod().isPatch()) { // do something }

Environment

None

Status

Assignee

Andrea Di Cesare

Reporter

Andrea Di Cesare

Labels

None

Fix versions

Affects versions

3.0.0

Priority

Major
Configure