Package com.aerospike.mapper.tools
Class ReactiveAeroMapper
java.lang.Object
com.aerospike.mapper.tools.ReactiveAeroMapper
- All Implemented Interfaces:
IBaseAeroMapper
,IReactiveAeroMapper
public class ReactiveAeroMapper extends Object implements IReactiveAeroMapper
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ReactiveAeroMapper.Builder
-
Method Summary
Modifier and Type Method Description <T> ReactiveVirtualList<T>
asBackedList(@NotNull Class<?> owningClazz, @NotNull Object key, @NotNull String binName, Class<T> elementClazz)
Create a reactive virtual list against an attribute on a class.<T> ReactiveVirtualList<T>
asBackedList(@NotNull Object object, @NotNull String binName, Class<T> elementClazz)
Create a reactive virtual list against an attribute on a class.IAeroMapper
asMapper()
<T> reactor.core.publisher.Mono<Boolean>
delete(@NotNull Class<T> clazz, @NotNull Object userKey)
Delete a record by specifying a class and a user key.reactor.core.publisher.Mono<Boolean>
delete(@NotNull Object object)
Delete a record by specifying an object.<T> reactor.core.publisher.Mono<Boolean>
delete(com.aerospike.client.policy.WritePolicy writePolicy, @NotNull Class<T> clazz, @NotNull Object userKey)
Delete a record by specifying a write policy, a class and a user key.reactor.core.publisher.Mono<Boolean>
delete(com.aerospike.client.policy.WritePolicy writePolicy, @NotNull Object object)
Delete a record by specifying a write policy and an object.<T> reactor.core.publisher.Mono<Void>
find(@NotNull Class<T> clazz, Function<T,Boolean> function)
Find a record by specifying a class and a Boolean function.com.aerospike.client.policy.BatchPolicy
getBatchPolicy(Class<?> clazz)
Return the batch policy to be used for the passed class.MappingConverter
getMappingConverter()
com.aerospike.client.policy.QueryPolicy
getQueryPolicy(Class<?> clazz)
Return the query policy to be used for the passed class.com.aerospike.client.reactor.IAerospikeReactorClient
getReactorClient()
com.aerospike.client.policy.Policy
getReadPolicy(Class<?> clazz)
Return the read policy to be used for the passed class.com.aerospike.client.policy.ScanPolicy
getScanPolicy(Class<?> clazz)
Return the scan policy to be used for the passed class.com.aerospike.client.policy.WritePolicy
getWritePolicy(Class<?> clazz)
Return the write policy to be used for the passed class.<T> reactor.core.publisher.Mono<T>
read(@NotNull Class<T> clazz, @NotNull Object userKey)
Read a record from the repository and map it to an instance of the passed class.<T> reactor.core.publisher.Flux<T>
read(@NotNull Class<T> clazz, @NotNull Object... userKeys)
Read a batch of records from the repository and map them to an instance of the passed class.<T> reactor.core.publisher.Mono<T>
read(@NotNull Class<T> clazz, @NotNull Object userKey, boolean resolveDependencies)
This method should not be used: It is used by mappers to correctly resolved dependencies.<T> reactor.core.publisher.Flux<T>
read(com.aerospike.client.policy.BatchPolicy batchPolicy, @NotNull Class<T> clazz, @NotNull Object... userKeys)
Read a batch of records from the repository and map them to an instance of the passed class.<T> reactor.core.publisher.Mono<T>
read(com.aerospike.client.policy.Policy readPolicy, @NotNull Class<T> clazz, @NotNull Object userKey)
Read a record from the repository and map it to an instance of the passed class.<T> reactor.core.publisher.Mono<T>
read(com.aerospike.client.policy.Policy readPolicy, @NotNull Class<T> clazz, @NotNull Object userKey, boolean resolveDependencies)
This method should not be used except by mappers<T> reactor.core.publisher.Mono<T>
readFromDigest(@NotNull Class<T> clazz, @javax.validation.constraints.NotNull byte[] digest)
Read a record from the repository and map it to an instance of the passed class, by providing a digest.<T> reactor.core.publisher.Mono<T>
readFromDigest(@NotNull Class<T> clazz, @javax.validation.constraints.NotNull byte[] digest, boolean resolveDependencies)
This method should not be used except by mappers<T> reactor.core.publisher.Mono<T>
readFromDigest(com.aerospike.client.policy.Policy readPolicy, @NotNull Class<T> clazz, @javax.validation.constraints.NotNull byte[] digest)
Read a record from the repository and map it to an instance of the passed class, by providing a digest.<T> reactor.core.publisher.Mono<T>
readFromDigest(com.aerospike.client.policy.Policy readPolicy, @NotNull Class<T> clazz, @javax.validation.constraints.NotNull byte[] digest, boolean resolveDependencies)
This method should not be used except by mappers<T> reactor.core.publisher.Mono<T>
save(@NotNull com.aerospike.client.policy.WritePolicy writePolicy, T object, String... binNames)
Save an object in the database with the given WritePolicy.<T> reactor.core.publisher.Flux<T>
save(@NotNull T... objects)
Save each object in the database.<T> reactor.core.publisher.Mono<T>
save(T object, String... binNames)
Save an object in the database.<T> reactor.core.publisher.Mono<T>
update(T object, String... binNames)
Updates the object in the database, merging the record with the existing record.
-
Method Details
-
save
public <T> reactor.core.publisher.Flux<T> save(@NotNull @NotNull T... objects)Save each object in the database. This method will perform a REPLACE on the existing record so any existing data will be overwritten by the data in the passed object. This is a convenience method forsave(A); save(B); save(C);
Not that no transactionality is implied by this method -- if any of the save methods fail, the exception will be thrown without trying the other objects, nor attempting to roll back previously saved objects- Specified by:
save
in interfaceIReactiveAeroMapper
- Parameters:
objects
- One or two objects to save.- Throws:
com.aerospike.client.AerospikeException
- an AerospikeException will be thrown in case of an error.
-
save
Save an object in the database. This method will perform a REPLACE on the existing record so any existing data will be overwritten by the data in the passed object- Specified by:
save
in interfaceIReactiveAeroMapper
- Parameters:
object
- The object to save.- Throws:
com.aerospike.client.AerospikeException
- an AerospikeException will be thrown in case of an error.
-
save
public <T> reactor.core.publisher.Mono<T> save(@NotNull @NotNull com.aerospike.client.policy.WritePolicy writePolicy, @NotNull T object, String... binNames)Save an object in the database with the given WritePolicy. This write policy will override any other set writePolicy so is effectively an upsert operation- Specified by:
save
in interfaceIReactiveAeroMapper
- Parameters:
writePolicy
- The write policy for the save operation.object
- The object to save.- Throws:
com.aerospike.client.AerospikeException
- an AerospikeException will be thrown in case of an error.
-
update
Updates the object in the database, merging the record with the existing record. This uses the RecordExistsAction of UPDATE. If bins are specified, only bins with the passed names will be updated (or all of them if null is passed)- Specified by:
update
in interfaceIReactiveAeroMapper
- Parameters:
object
- The object to update.- Throws:
com.aerospike.client.AerospikeException
- an AerospikeException will be thrown in case of an error.
-
readFromDigest
public <T> reactor.core.publisher.Mono<T> readFromDigest(@NotNull @NotNull Class<T> clazz, @NotNull @javax.validation.constraints.NotNull byte[] digest)Read a record from the repository and map it to an instance of the passed class, by providing a digest.- Specified by:
readFromDigest
in interfaceIReactiveAeroMapper
- Parameters:
clazz
- - The type of the record.digest
- - The Aerospike digest (Unique server hash value generated from set name and user key).- Returns:
- The returned mapped record.
- Throws:
com.aerospike.client.AerospikeException
- an AerospikeException will be thrown in case of an error.
-
readFromDigest
public <T> reactor.core.publisher.Mono<T> readFromDigest(@NotNull @NotNull Class<T> clazz, @NotNull @javax.validation.constraints.NotNull byte[] digest, boolean resolveDependencies) throws com.aerospike.client.AerospikeExceptionThis method should not be used except by mappers- Specified by:
readFromDigest
in interfaceIReactiveAeroMapper
- Throws:
com.aerospike.client.AerospikeException
-
readFromDigest
public <T> reactor.core.publisher.Mono<T> readFromDigest(com.aerospike.client.policy.Policy readPolicy, @NotNull @NotNull Class<T> clazz, @NotNull @javax.validation.constraints.NotNull byte[] digest)Read a record from the repository and map it to an instance of the passed class, by providing a digest.- Specified by:
readFromDigest
in interfaceIReactiveAeroMapper
- Parameters:
readPolicy
- - The read policy for the read operation.clazz
- - The type of the record.digest
- - The Aerospike digest (Unique server hash value generated from set name and user key).- Returns:
- The returned mapped record.
- Throws:
com.aerospike.client.AerospikeException
- an AerospikeException will be thrown in case of an error.
-
readFromDigest
public <T> reactor.core.publisher.Mono<T> readFromDigest(com.aerospike.client.policy.Policy readPolicy, @NotNull @NotNull Class<T> clazz, @NotNull @javax.validation.constraints.NotNull byte[] digest, boolean resolveDependencies)This method should not be used except by mappers- Specified by:
readFromDigest
in interfaceIReactiveAeroMapper
-
read
public <T> reactor.core.publisher.Mono<T> read(@NotNull @NotNull Class<T> clazz, @NotNull @NotNull Object userKey)Read a record from the repository and map it to an instance of the passed class.- Specified by:
read
in interfaceIReactiveAeroMapper
- Parameters:
clazz
- - The type of the record.userKey
- - The key of the record. The namespace and set will be derived from the values specified on the passed class.- Returns:
- The returned mapped record.
- Throws:
com.aerospike.client.AerospikeException
- an AerospikeException will be thrown in case of an error.
-
read
public <T> reactor.core.publisher.Mono<T> read(@NotNull @NotNull Class<T> clazz, @NotNull @NotNull Object userKey, boolean resolveDependencies)This method should not be used: It is used by mappers to correctly resolved dependencies. Use read(clazz, userKey) instead- Specified by:
read
in interfaceIReactiveAeroMapper
-
read
public <T> reactor.core.publisher.Mono<T> read(com.aerospike.client.policy.Policy readPolicy, @NotNull @NotNull Class<T> clazz, @NotNull @NotNull Object userKey)Read a record from the repository and map it to an instance of the passed class.- Specified by:
read
in interfaceIReactiveAeroMapper
- Parameters:
readPolicy
- - The read policy for the read operation.clazz
- - The type of the record.userKey
- - The key of the record. The namespace and set will be derived from the values specified on the passed class.- Returns:
- The returned mapped record.
- Throws:
com.aerospike.client.AerospikeException
- an AerospikeException will be thrown in case of an error.
-
read
public <T> reactor.core.publisher.Mono<T> read(com.aerospike.client.policy.Policy readPolicy, @NotNull @NotNull Class<T> clazz, @NotNull @NotNull Object userKey, boolean resolveDependencies)This method should not be used except by mappers- Specified by:
read
in interfaceIReactiveAeroMapper
-
read
public <T> reactor.core.publisher.Flux<T> read(@NotNull @NotNull Class<T> clazz, @NotNull @NotNull Object... userKeys)Read a batch of records from the repository and map them to an instance of the passed class.- Specified by:
read
in interfaceIReactiveAeroMapper
- Parameters:
clazz
- - The type of the record.userKeys
- - The keys of the record. The namespace and set will be derived from the values specified on the passed class.- Returns:
- The returned mapped records.
- Throws:
com.aerospike.client.AerospikeException
- an AerospikeException will be thrown in case of an error.
-
read
public <T> reactor.core.publisher.Flux<T> read(com.aerospike.client.policy.BatchPolicy batchPolicy, @NotNull @NotNull Class<T> clazz, @NotNull @NotNull Object... userKeys)Read a batch of records from the repository and map them to an instance of the passed class.- Specified by:
read
in interfaceIReactiveAeroMapper
- Parameters:
batchPolicy
- A given batch policy.clazz
- - The type of the record.userKeys
- - The keys of the record. The namespace and set will be derived from the values specified on the passed class.- Returns:
- The returned mapped records.
- Throws:
com.aerospike.client.AerospikeException
- an AerospikeException will be thrown in case of an error.
-
delete
public <T> reactor.core.publisher.Mono<Boolean> delete(@NotNull @NotNull Class<T> clazz, @NotNull @NotNull Object userKey)Delete a record by specifying a class and a user key.- Specified by:
delete
in interfaceIReactiveAeroMapper
- Parameters:
clazz
- - The type of the record.userKey
- - The key of the record. The namespace and set will be derived from the values specified on the passed class.- Returns:
- whether record existed on server before deletion
- Throws:
com.aerospike.client.AerospikeException
- an AerospikeException will be thrown in case of an error.
-
delete
public <T> reactor.core.publisher.Mono<Boolean> delete(com.aerospike.client.policy.WritePolicy writePolicy, @NotNull @NotNull Class<T> clazz, @NotNull @NotNull Object userKey)Delete a record by specifying a write policy, a class and a user key.- Specified by:
delete
in interfaceIReactiveAeroMapper
- Parameters:
writePolicy
- - The write policy for the delete operation.clazz
- - The type of the record.userKey
- - The key of the record. The namespace and set will be derived from the values specified on the passed class.- Returns:
- whether record existed on server before deletion
- Throws:
com.aerospike.client.AerospikeException
- an AerospikeException will be thrown in case of an error.
-
delete
Delete a record by specifying an object.- Specified by:
delete
in interfaceIReactiveAeroMapper
- Parameters:
object
- The object to delete.- Returns:
- whether record existed on server before deletion
- Throws:
com.aerospike.client.AerospikeException
- an AerospikeException will be thrown in case of an error.
-
delete
public reactor.core.publisher.Mono<Boolean> delete(com.aerospike.client.policy.WritePolicy writePolicy, @NotNull @NotNull Object object)Delete a record by specifying a write policy and an object.- Specified by:
delete
in interfaceIReactiveAeroMapper
- Parameters:
writePolicy
- - The write policy for the delete operation.object
- The object to delete.- Returns:
- whether record existed on server before deletion
- Throws:
com.aerospike.client.AerospikeException
- an AerospikeException will be thrown in case of an error.
-
asBackedList
public <T> ReactiveVirtualList<T> asBackedList(@NotNull @NotNull Object object, @NotNull @NotNull String binName, Class<T> elementClazz)Create a reactive virtual list against an attribute on a class. The list does all operations to the database and does not affect the underlying class, and is useful for situation when operations are needed to affect the database without having to return all the elements on the list each time. For example, consider a set of transactions associated with a credit card. Common operations might be- Return the last N transactions
- insert a new transaction into the list
- Specified by:
asBackedList
in interfaceIReactiveAeroMapper
- Type Parameters:
T
- the type of the elements in the list.- Parameters:
object
- The object that will use as a base for the virtual list.binName
- The Aerospike bin name.elementClazz
- The class of the elements in the list.- Returns:
- A reactive virtual list.
-
asBackedList
public <T> ReactiveVirtualList<T> asBackedList(@NotNull @NotNull Class<?> owningClazz, @NotNull @NotNull Object key, @NotNull @NotNull String binName, Class<T> elementClazz)Create a reactive virtual list against an attribute on a class. The list does all operations to the database and does not affect the underlying class, and is useful for situation when operations are needed to affect the database without having to return all the elements on the list each time. Note that the object being mapped does not need to actually exist in this case. The owning class is used purely for the definitions of how to map the list elements (are they to be mapped in the database as a list or a map, is each element a list or a map, etc), as well as using the namespace / set definition for the location to map into the database. The passed key is used to map the object to the database. For example, consider a set of transactions associated with a credit card. Common operations might be- Return the last N transactions
- insert a new transaction into the list
- Specified by:
asBackedList
in interfaceIReactiveAeroMapper
- Type Parameters:
T
- the type of the elements in the list.- Parameters:
owningClazz
- Used for the definitions of how to map the list elements.key
- The key to map the object to the database.binName
- The Aerospike bin name.elementClazz
- The class of the elements in the list.- Returns:
- A reactive virtual list.
-
find
public <T> reactor.core.publisher.Mono<Void> find(@NotNull @NotNull Class<T> clazz, Function<T,Boolean> function) throws com.aerospike.client.AerospikeExceptionFind a record by specifying a class and a Boolean function.- Specified by:
find
in interfaceIReactiveAeroMapper
- Parameters:
clazz
- - The type of the record.function
- a Boolean function.- Throws:
com.aerospike.client.AerospikeException
- an AerospikeException will be thrown in case of an error.
-
getReactorClient
public com.aerospike.client.reactor.IAerospikeReactorClient getReactorClient()- Specified by:
getReactorClient
in interfaceIReactiveAeroMapper
-
getMappingConverter
- Specified by:
getMappingConverter
in interfaceIBaseAeroMapper
-
getReadPolicy
Return the read policy to be used for the passed class. This is a convenience method only and should rarely be needed- Specified by:
getReadPolicy
in interfaceIBaseAeroMapper
- Parameters:
clazz
- - the class to return the read policy for.- Returns:
- - the appropriate read policy. If none is set, the client's readPolicyDefault is returned.
-
getWritePolicy
Return the write policy to be used for the passed class. This is a convenience method only and should rarely be needed- Specified by:
getWritePolicy
in interfaceIBaseAeroMapper
- Parameters:
clazz
- - the class to return the write policy for.- Returns:
- - the appropriate write policy. If none is set, the client's writePolicyDefault is returned.
-
getBatchPolicy
Return the batch policy to be used for the passed class. This is a convenience method only and should rarely be needed- Specified by:
getBatchPolicy
in interfaceIBaseAeroMapper
- Parameters:
clazz
- - the class to return the batch policy for.- Returns:
- - the appropriate batch policy. If none is set, the client's batchPolicyDefault is returned.
-
getScanPolicy
Return the scan policy to be used for the passed class. This is a convenience method only and should rarely be needed- Specified by:
getScanPolicy
in interfaceIBaseAeroMapper
- Parameters:
clazz
- - the class to return the scan policy for.- Returns:
- - the appropriate scan policy. If none is set, the client's scanPolicyDefault is returned.
-
getQueryPolicy
Return the query policy to be used for the passed class. This is a convenience method only and should rarely be needed- Specified by:
getQueryPolicy
in interfaceIBaseAeroMapper
- Parameters:
clazz
- - the class to return the query policy for.- Returns:
- - the appropriate query policy. If none is set, the client's queryPolicyDefault is returned.
-
asMapper
- Specified by:
asMapper
in interfaceIBaseAeroMapper
-