java.lang.Object
org.proto4j.redis.Redis
public final class Redis
extends java.lang.Object
Redis adapts a Java interface into calls to a connected database by using
annotations on the declared methods and its parameters. Create instances
with providing your interface class and the
SQLConfiguration or
SQLSource to the create(java.lang.Class<API>, org.proto4j.redis.sql.SQLConfiguration) method.
For example (with usage of the SQLite factory),
SQLConfiguration config = new SQLiteConfiguration("mydb");
MyApi api = Redis.create(MyApi.class, config);
List<User> list = api.fetchUsersFrom("table_two");
- Version:
- 1.0
- Author:
- MatrixEditor
-
Method Summary
Modifier and Type Method Description static <API> APIcreate(java.lang.Class<API> cls, SQLConfiguration configuration)Create an implementation of the API methods defined by theapiinterface.static <API> APIcreate(java.lang.Class<API> cls, SQLSource source)Create an implementation of the API methods defined by theapiinterface.
-
Method Details
-
create
Create an implementation of the API methods defined by theapiinterface.Method parameters annotated with
Paramcan be used to dynamically replace parts of the sql statement. Replacement sections are denoted by an identifier surrounded by curly braces (e.g., "{abc}").The creation of
SQLSourceandSQLServiceobjects are delegated to the specified class that implements the basic functions from theSQLFactoryinterface.For example,
@SQL(SQLiteFactory.FACTORY) public interface UserStorage { @SQL.Select("select * from {table}") public List<User> fetchUsersFrom(@Param("table") String tb); }- Type Parameters:
API- the type of the api- Parameters:
cls- the interface tha will be implementedconfiguration- theSQLConfigurationinstance used to create aSQLSource.- Returns:
- a new instance for the specified interface type
-
create
Create an implementation of the API methods defined by theapiinterface.- Type Parameters:
API- the type of the api- Parameters:
cls- the interface tha will be implementedsource- theSQLSourceinstance with aSQLConfiguration.- Returns:
- a new instance for the specified interface type
- See Also:
create(Class, SQLConfiguration)
-