Skip to content

add a common object for browse and search request - #189

Open
as-smets wants to merge 1 commit into
Constructor-io:masterfrom
as-smets:chore/actract-base-search-browse-request
Open

as-smets wants to merge 1 commit into
Constructor-io:masterfrom
as-smets:chore/actract-base-search-browse-request

Conversation

@as-smets

@as-smets as-smets commented Sep 1, 2026

Copy link
Copy Markdown

Closes issue #188

To be able to factorize code between search and browse common request parameters

I didn't want the object to be called only BaseRequest so I chose BrowseSearchBaseRequest but not totally convinced

Copilot AI lite review requested due to automatic review settings September 1, 2026 07:41
@as-smets
as-smets requested a review from a team as a code owner September 1, 2026 07:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the Java client’s browse/search request models by extracting shared request parameters into a common base class, reducing duplication between BrowseRequest and SearchRequest.

Changes:

  • Introduces BrowseSearchBaseRequest to hold common browse/search parameters (pagination, facets, sorting, etc.).
  • Updates SearchRequest to extend the new base request and removes duplicated fields/accessors.
  • Updates BrowseRequest to extend the new base request and removes duplicated fields/accessors.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
constructorio-client/src/main/java/io/constructor/client/SearchRequest.java Switches search request model to inherit shared parameters from the new base request.
constructorio-client/src/main/java/io/constructor/client/BrowseSearchBaseRequest.java Adds the new shared base request containing common browse/search fields and accessors.
constructorio-client/src/main/java/io/constructor/client/BrowseRequest.java Switches browse request model to inherit shared parameters from the new base request.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@as-smets
as-smets force-pushed the chore/actract-base-search-browse-request branch from af7ed1c to 13896bd Compare September 1, 2026 12:24

@Alexey-Pavlov Alexey-Pavlov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Left a few comments there and there

Comment on lines +28 to +31
/**
* Object with common request fields of search and browse
*
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like mvn spotless:check fails on this file

How about running mvn spotless:apply and committing the result? For this spot, it gives:

Suggested change
/**
* Object with common request fields of search and browse
*
*/
/** Object with common request fields of search and browse */

Comment on lines +267 to +270
/**
* @param filterMatchTypes the filterMatchTypes to set. Please refer to the relevant Search/Browse API endpoint documentation for details.
* Possible values 'all', 'any' or 'none'
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the second spot spotless flags (see my comment on the constructor's Javadoc). While it's being rewrapped, I think it's worth keeping a link here too.

What do you think about linking both pages? That keeps it endpoint-agnostic, as Copilot's comment asked, without losing the pointer. Formatted with spotless:apply:

Suggested change
/**
* @param filterMatchTypes the filterMatchTypes to set. Please refer to the relevant Search/Browse API endpoint documentation for details.
* Possible values 'all', 'any' or 'none'
*/
/**
* @param filterMatchTypes the filterMatchTypes to set. Please refer to
* https://docs.constructor.com/reference/v1-search-get-search-results or
* https://docs.constructor.com/reference/v1-browse-get-browse-results for details. Possible
* values 'all', 'any' or 'none'
*/

* @param query the term to return search results for
*/
public SearchRequest(String query) throws IllegalArgumentException {
super();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: the explicit super(); is what the compiler inserts anyway when a constructor doesn't start with a this(…) or super(…) call, and the other subclass constructor in this package, QuizRequest(String quizId), only spells it out because it passes super(quizId). How about dropping it here and in BrowseRequest (same note there)?

Suggested change
super();

* @param filterValue filter value to display results from
*/
public BrowseRequest(String filterName, String filterValue) throws IllegalArgumentException {
super();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick, same as in SearchRequest: this super(); is what the compiler inserts anyway when a constructor doesn't start with a this(…) or super(…) call. How about dropping it?

import java.util.Map;

/** Constructor.io base Search/Browse Request */
public class BrowseSearchBaseRequest {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this class wants to be abstract. Right now BrowseSearchBaseRequest is a concrete public class with a public no-arg constructor, so new BrowseSearchBaseRequest() compiles, but there's nothing you can do with that object: every ConstructorIO entry point takes the concrete type, search(SearchRequest req, …) or browse(BrowseRequest req, …), and the base class has no required parameter of its own. It only exists to be extended.

How about abstract with a protected constructor (next comment)? Then the compiler rules the direct instantiation out, and the public API gains a type to pass around rather than a type to build. QuizRequestBase is concrete, so this is a small departure from that precedent, but that class is at least accepted somewhere, by createQuizRequest(QuizRequestBase req, …), whereas nothing accepts this one.

Suggested change
public class BrowseSearchBaseRequest {
public abstract class BrowseSearchBaseRequest {

Comment on lines +32 to +33
public BrowseSearchBaseRequest() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second half of the change from my comment on the class line: protected here means only the classes that extend this one, SearchRequest and BrowseRequest, can call this constructor, and they are the only ones that ever do

Suggested change
public BrowseSearchBaseRequest() {
protected BrowseSearchBaseRequest() {

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants