Skip to content

Simplify QueryService #26913

Closed
Closed
@amatosg

Description

@amatosg
Overview of the feature request

Remove many, many lines of code and move them to the abstract class QueryService.

Motivation for or Use Case

This feature is important because the code will be less complex, therefore cleaner and more redeable and maintainable.

Instead of having many, many if statements,

if (criteria.getContact() != null) {
    specification = specification.and(buildStringSpecification(criteria.getContact(), Address_.contact));
}

there would be only one line:

specification = getStringSpecification(criteria.getContact(), specification, Address_.contact);

The QueryService abstract class would have this method (or something similar)

protected Specification<T> getStringSpecification(
        StringFilter stringFilter,
        Specification<T> specification,
        SingularAttribute<T, String> attribute
    ) {
        if (stringFilter != null) {
            specification = specification.and(buildStringSpecification(stringFilter, attribute));
        }
        return specification;
    }

This can be applied to other specifications (booleans, ranged, etc)

Related issues or PR
  • Checking this box is mandatory (this is just to show you read everything)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions