I am using @RequestParam
to get the column name against which I want to sort my results.
public ResponseEntity<Map<String, Object>> method(@PathVariable("tenant_id") Integer tenantId,
@PathVariable("asset_location_id") Integer assetLocationId,
@RequestParam(defaultValue = "") String search_keyword,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "10") int size,
@RequestParam(defaultValue = "asset_name") String sort_field,
@RequestParam(defaultValue = "asc") String sort_dir) {}
How I can make sure sort_field
has the only possible column names which are possible in a given response?