org.redisson.api.annotation.RId Java Examples

The following examples show how to use org.redisson.api.annotation.RId. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LongGenerator.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Override
public Long resolve(Class<?> value, RId id, String idFieldName, CommandAsyncExecutor commandAsyncExecutor) {
    if (commandAsyncExecutor instanceof CommandBatchService) {
        throw new IllegalStateException("this generator couldn't be used in batch");
    }

    return new RedissonAtomicLong(commandAsyncExecutor, this.getClass().getCanonicalName()
            + "{" + value.getCanonicalName() + "}:" + idFieldName).incrementAndGet();
}
 
Example #2
Source File: RequiredIdResolver.java    From redisson with Apache License 2.0 4 votes vote down vote up
@Override
public Object resolve(Class<?> cls, RId annotation, String idFieldName, CommandAsyncExecutor commandAsyncExecutor) {
    throw new IllegalArgumentException("id value is not defined for instance of " + cls);
}
 
Example #3
Source File: UUIDGenerator.java    From redisson with Apache License 2.0 4 votes vote down vote up
@Override
public String resolve(Class<?> value, RId id, String idFieldName, CommandAsyncExecutor commandAsyncExecutor) {
    return UUID.randomUUID().toString();
}
 
Example #4
Source File: AccessorInterceptor.java    From redisson with Apache License 2.0 4 votes vote down vote up
private static String getREntityIdFieldName(Object o) {
    return Introspectior
            .getFieldsWithAnnotation(o.getClass().getSuperclass(), RId.class)
            .getOnly()
            .getName();
}
 
Example #5
Source File: RIdResolver.java    From redisson with Apache License 2.0 2 votes vote down vote up
/**
 * RLiveObjectService instantiate the class and invokes this method to get
 * a value used as the value for the field with RId annotation. 
 * 
 * @param cls the class of the LiveObject.
 * @param annotation the RId annotation used in the class.
 * @param idFieldName field id
 * @param commandAsyncExecutor instance
 * @return resolved RId field value.
 */
V resolve(Class<?> cls, RId annotation, String idFieldName, CommandAsyncExecutor commandAsyncExecutor);