Class SearchOperatorBuilder
java.lang.Object
net.ygbstudio.jbrave.core.builders.SearchOperatorBuilder
A builder class for constructing search operators.
This class provides a fluent API for constructing search operators. The build()
method returns the constructed search operator string.
Example usage:
String searchOperator = SearchOperatorBuilder.builder()
.filetype("html")
.and(op -> op.loc("ca"), op -> op.intitle("java"))
.build();
This will construct the search operator string filetype:html loc:caANDintitle:java.
-
Method Summary
Modifier and TypeMethodDescriptionAdds the logicalANDoperator and its corresponding values to the builder.and(@NotNull UnaryOperator<SearchOperatorBuilder> operatorOne, @NotNull UnaryOperator<SearchOperatorBuilder> operatorTwo) Adds the logicalANDoperator and its corresponding values to the builder.build()Constructs the search operator string by concatenating the values of the builder with the corresponding operators.static @NotNull SearchOperatorBuilderbuilder()Creates a new instance of theSearchOperatorBuilderclass.clear()Clears the search operator builder by removing all the operators and their corresponding values.exactMatch(@NotNull String exactMatch) Adds double quotes to the corresponding value (exact search term match) and adds it to the builder.Adds a "-" operator with its corresponding value to the builder.Adds an "ext" operator and its corresponding value to the builder.Adds a "filetype" operator and its corresponding value to the .Adds an "+" operator with its corresponding value to the builder.Adds an "inpage" operator and its corresponding value to the builder.Adds an "intitle" operator and its corresponding value to the builder.Adds a "lang" operator and its corresponding value to the builder.Adds a "loc" operator and its corresponding value to the builder.Adds the logicalNOToperator and its corresponding values to the builder.not(@NotNull UnaryOperator<SearchOperatorBuilder> operatorOne, @NotNull UnaryOperator<SearchOperatorBuilder> operatorTwo) Adds the logicalNOToperator and its corresponding values to the builder.Adds the logicalORoperator and its corresponding values to the builder.or(@NotNull UnaryOperator<SearchOperatorBuilder> operatorOne, @NotNull UnaryOperator<SearchOperatorBuilder> operatorTwo) Adds the logicalORoperator and its corresponding values to the builder.Adds a "site" operator and its corresponding value to the builder.
-
Method Details
-
builder
Creates a new instance of theSearchOperatorBuilderclass.- Returns:
- a new instance of the
SearchOperatorBuilderclass
-
ext
Adds an "ext" operator and its corresponding value to the builder.- Parameters:
extension- the file extension to search for- Returns:
- the current instance of the
SearchOperatorBuilderclass
-
filetype
Adds a "filetype" operator and its corresponding value to the .- Parameters:
filetype- the file type to search for- Returns:
- the current instance of the
SearchOperatorBuilderclass
-
intitle
Adds an "intitle" operator and its corresponding value to the builder.- Parameters:
intitleContent- the content to search for in the title- Returns:
- the current instance of the
SearchOperatorBuilderclass
-
inpage
Adds an "inpage" operator and its corresponding value to the builder.- Parameters:
inpageContent- the content to search for within the page- Returns:
- the current instance of the
SearchOperatorBuilderclass
-
lang
Adds a "lang" operator and its corresponding value to the builder.- Parameters:
language- the language to search for- Returns:
- the current instance of the
SearchOperatorBuilderclass
-
loc
Adds a "loc" operator and its corresponding value to the builder.- Parameters:
location- the location to search for- Returns:
- the current instance of the
SearchOperatorBuilderclass
-
site
Adds a "site" operator and its corresponding value to the builder.- Parameters:
site- the site to search for- Returns:
- the current instance of the
SearchOperatorBuilderclass
-
include
Adds an "+" operator with its corresponding value to the builder.- Parameters:
toInclude- the content to include in the search- Returns:
- the current instance of the
SearchOperatorBuilderclass
-
exclude
Adds a "-" operator with its corresponding value to the builder.- Parameters:
toExclude- the content to exclude from the search- Returns:
- the current instance of the
SearchOperatorBuilderclass
-
exactMatch
Adds double quotes to the corresponding value (exact search term match) and adds it to the builder.- Parameters:
exactMatch- the exact match to search for- Returns:
- the current instance of the
SearchOperatorBuilderclass
-
and
public SearchOperatorBuilder and(@NotNull @NotNull String termOne, @NotNull @NotNull String termTwo) Adds the logicalANDoperator and its corresponding values to the builder.- Parameters:
termOne- the first term to search fortermTwo- the second term to search for- Returns:
- the current instance of the
SearchOperatorBuilderclass
-
and
public SearchOperatorBuilder and(@NotNull @NotNull UnaryOperator<SearchOperatorBuilder> operatorOne, @NotNull @NotNull UnaryOperator<SearchOperatorBuilder> operatorTwo) Adds the logicalANDoperator and its corresponding values to the builder. Combines two builder lambdas in order to construct logical expressions with search operators.- Parameters:
operatorOne- the first operator to search foroperatorTwo- the second operator to search for- Returns:
- the current instance of the
SearchOperatorBuilderclass
-
or
Adds the logicalORoperator and its corresponding values to the builder.- Parameters:
termOne- the first term to search fortermTwo- the second term to search for- Returns:
- the current instance of the
SearchOperatorBuilderclass
-
or
public SearchOperatorBuilder or(@NotNull @NotNull UnaryOperator<SearchOperatorBuilder> operatorOne, @NotNull @NotNull UnaryOperator<SearchOperatorBuilder> operatorTwo) Adds the logicalORoperator and its corresponding values to the builder. Combines two builder lambdas in order to construct logical expressions with search operators.- Parameters:
operatorOne- the first operator to search foroperatorTwo- the second operator to search for- Returns:
- the current instance of the
SearchOperatorBuilderclass
-
not
public SearchOperatorBuilder not(@NotNull @NotNull String termOne, @NotNull @NotNull String termTwo) Adds the logicalNOToperator and its corresponding values to the builder.- Parameters:
termOne- the term to search for that should not be presenttermTwo- the term that should not be present- Returns:
- the current instance of the
SearchOperatorBuilderclass
-
not
public SearchOperatorBuilder not(@NotNull @NotNull UnaryOperator<SearchOperatorBuilder> operatorOne, @NotNull @NotNull UnaryOperator<SearchOperatorBuilder> operatorTwo) Adds the logicalNOToperator and its corresponding values to the builder. Combines two builder lambdas in order to construct logical expressions with search operators.- Parameters:
operatorOne- the first operator to search for that should not be presentoperatorTwo- the second operator to search for that should not be present- Returns:
- the current instance of the
SearchOperatorBuilderclass
-
clear
Clears the search operator builder by removing all the operators and their corresponding values.- Returns:
- the current instance of the
SearchOperatorBuilderclass
-
build
Constructs the search operator string by concatenating the values of the builder with the corresponding operators.- Returns:
- the search operator string
-