All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.camunda.search.clients.query.SearchQuery Maven / Gradle / Ivy

There is a newer version: 8.7.0-alpha2
Show newest version
/*
 * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under
 * one or more contributor license agreements. See the NOTICE file distributed
 * with this work for additional information regarding copyright ownership.
 * Licensed under the Camunda License 1.0. You may not use this file
 * except in compliance with the Camunda License 1.0.
 */
package io.camunda.search.clients.query;

import static io.camunda.search.clients.query.SearchQueryBuilders.query;

import io.camunda.util.ObjectBuilder;
import java.util.function.Function;

public final record SearchQuery(SearchQueryOption queryOption) {

  public static SearchQuery of(final Function> fn) {
    return query(fn);
  }

  public static final class Builder implements ObjectBuilder {

    private SearchQueryOption queryOption;

    public Builder bool(final SearchBoolQuery query) {
      queryOption = query;
      return this;
    }

    public Builder bool(
        final Function> fn) {
      return bool(SearchQueryBuilders.bool(fn));
    }

    public Builder constantScore(final SearchConstantScoreQuery query) {
      queryOption = query;
      return this;
    }

    public Builder constantScore(
        final Function>
            fn) {
      return constantScore(SearchQueryBuilders.constantScore(fn));
    }

    public Builder exists(final SearchExistsQuery query) {
      queryOption = query;
      return this;
    }

    public Builder exists(
        final Function> fn) {
      return exists(SearchQueryBuilders.exists(fn));
    }

    public Builder hasChild(final SearchHasChildQuery query) {
      queryOption = query;
      return this;
    }

    public Builder hasChild(
        final Function> fn) {
      return hasChild(SearchQueryBuilders.hasChild(fn));
    }

    public Builder ids(final SearchIdsQuery query) {
      queryOption = query;
      return this;
    }

    public Builder ids(final Function> fn) {
      return ids(SearchQueryBuilders.ids(fn));
    }

    public Builder match(final SearchMatchQuery query) {
      queryOption = query;
      return this;
    }

    public Builder match(
        final Function> fn) {
      return match(SearchQueryBuilders.match(fn));
    }

    public Builder matchAll() {
      queryOption = new SearchMatchAllQuery.Builder().build();
      return this;
    }

    public Builder matchNone(final SearchMatchNoneQuery query) {
      queryOption = new SearchMatchNoneQuery.Builder().build();
      return this;
    }

    public Builder prefix(final SearchPrefixQuery query) {
      queryOption = query;
      return this;
    }

    public Builder prefix(
        final Function> fn) {
      return prefix(SearchQueryBuilders.prefix(fn));
    }

    public Builder range(final SearchRangeQuery query) {
      queryOption = query;
      return this;
    }

    public Builder range(
        final Function> fn) {
      return range(SearchQueryBuilders.range(fn));
    }

    public Builder term(final SearchTermQuery query) {
      queryOption = query;
      return this;
    }

    public Builder term(
        final Function> fn) {
      return term(SearchQueryBuilders.term(fn));
    }

    public Builder terms(final SearchTermsQuery query) {
      queryOption = query;
      return this;
    }

    public Builder terms(
        final Function> fn) {
      return terms(SearchQueryBuilders.terms(fn));
    }

    public Builder wildcard(final SearchWildcardQuery query) {
      queryOption = query;
      return this;
    }

    public Builder wildcard(
        final Function> fn) {
      return wildcard(SearchQueryBuilders.wildcard(fn));
    }

    @Override
    public SearchQuery build() {
      return new SearchQuery(queryOption);
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy