Package io.manebot.database.search
Interface SearchHandler<T>
-
- Type Parameters:
T
- search common entity class. Should be mapped to a database.
public interface SearchHandler<T>
SearchHandlers are used to handle Search queries, which are in turn constructed by command arguments passed to commands with the CommandArgumentSearch type. A SearchHandler takes a raw query from the aforementioned argument type, validates it, and executes it against the database. There are three search component types, all parsed by the Search class, and passed to a SearchHandler: 1. Argument Example: name:value 2. Command Example: command 3. String Example: "multi word string" These can be combined together with operators, such as '+', '-', and '~', denoting AND, AND NOT, and OR respectively. OR (~) is implied, and is assumed when no operator is explicitly defined. Operators at the beginning a query are not allowed. "title" -banned +by:user
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
SearchHandler.Builder<T>
Builds SearchHandlers.static interface
SearchHandler.Clause<T>
Represents a WHERE clause.
-
Method Summary
Modifier and Type Method Description SearchArgumentHandler
getArgumentHandler(java.lang.String name)
Gets the argument handler for a given argument.SearchArgumentHandler
getCommandHandler(java.lang.String name)
Gets the command handler for a given command label.Database
getDatabase()
Gets the database associated with this search handler.java.lang.Class<T>
getEntityClass()
Gets the entity class associated with this search handler.SearchArgumentHandler
getStringHandler()
Gets the default string handler for the search handler.SearchResult<T>
search(Search search, int maxResults)
Executes a search on a specific search object.
-
-
-
Method Detail
-
getEntityClass
java.lang.Class<T> getEntityClass()
Gets the entity class associated with this search handler.- Returns:
- entity class.
-
getDatabase
Database getDatabase()
Gets the database associated with this search handler.- Returns:
- Database instance.
-
getArgumentHandler
SearchArgumentHandler getArgumentHandler(java.lang.String name)
Gets the argument handler for a given argument.- Parameters:
name
- Argument name to check.- Returns:
- SearchArgumentHandler instance if found, or null if none was found.
-
getCommandHandler
SearchArgumentHandler getCommandHandler(java.lang.String name)
Gets the command handler for a given command label.- Parameters:
name
- Command name to check.- Returns:
- SearchArgumentHandler instance if found, or null if none was found.
-
getStringHandler
SearchArgumentHandler getStringHandler()
Gets the default string handler for the search handler.- Returns:
- Default SearchArgumentHandler for string arguments, or null if none was found.
-
search
SearchResult<T> search(Search search, int maxResults) throws java.sql.SQLException, java.lang.IllegalArgumentException
Executes a search on a specific search object.- Parameters:
search
- Search object to parse, containing predicates to filter down the specified entity list.maxResults
- Maximum page result count- Returns:
- Immutable list of entities found by the search.
- Throws:
java.sql.SQLException
- if there was a SQL exception executing a completed or incomplete search.java.lang.IllegalArgumentException
- if the arguments provided by the search argument were invalid.
-
-