Skip to content

Commit

Permalink
Rename Lambda parameters by type in JedisConnection and JedisInvoker.
Browse files Browse the repository at this point in the history
Refactor, organize source and fix compiler warnings.
  • Loading branch information
jxblum committed Sep 20, 2023
1 parent 384b1df commit fe6e65f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private Object doInvoke(boolean status, Function<Jedis, Object> directFunction,
Function<ResponseCommands, Response<Object>> pipelineFunction, Converter<Object, Object> converter,
Supplier<Object> nullDefault) {

return doWithJedis(it -> {
return doWithJedis(jedis -> {

if (isQueueing()) {

Expand All @@ -225,7 +225,7 @@ private Object doInvoke(boolean status, Function<Jedis, Object> directFunction,
return null;
}

Object result = directFunction.apply(getJedis());
Object result = directFunction.apply(jedis);

if (result == null) {
return nullDefault.get();
Expand Down Expand Up @@ -378,7 +378,7 @@ public void openPipeline() {
}

if (pipeline == null) {
pipeline = jedis.pipelined();
pipeline = getJedis().pipelined();
}
}

Expand Down Expand Up @@ -411,7 +411,8 @@ private List<Object> convertPipelineResults() {
Object data = result.get();

if (!result.isStatus()) {
results.add(result.conversionRequired() ? result.convert(data) : data);
Object resolvedData = result.conversionRequired() ? result.convert(data) : data;
results.add(resolvedData);
}
} catch (JedisDataException e) {
DataAccessException dataAccessException = convertJedisAccessException(e);
Expand Down Expand Up @@ -550,17 +551,20 @@ JedisInvoker invokeStatus() {
}

<T> JedisResult<T, T> newJedisResult(Response<T> response) {
return JedisResultBuilder.<T, T> forResponse(response).build();
return JedisResultBuilder.<T, T>forResponse(response).build();
}

<T, R> JedisResult<T, R> newJedisResult(Response<T> response, Converter<T, R> converter, Supplier<R> defaultValue) {

return JedisResultBuilder.<T, R> forResponse(response).mappedWith(converter)
.convertPipelineAndTxResults(convertPipelineAndTxResults).mapNullTo(defaultValue).build();
return JedisResultBuilder.<T, R>forResponse(response)
.convertPipelineAndTxResults(this.convertPipelineAndTxResults)
.mapNullTo(defaultValue)
.mappedWith(converter)
.build();
}

<T> JedisStatusResult<T, T> newStatusResult(Response<T> response) {
return JedisResultBuilder.<T, T> forResponse(response).buildStatusResult();
return JedisResultBuilder.<T, T>forResponse(response).buildStatusResult();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ <R> R just(ConnectionFunction0<R> function) {

Assert.notNull(function, "ConnectionFunction must not be null");

return synchronizer.invoke(function::apply, it -> {
return synchronizer.invoke(function::apply, responseCommands -> {
throw new InvalidDataAccessApiUsageException("Operation not supported by Jedis in pipelining/transaction mode");
}, Converters.identityConverter(), () -> null);
}
Expand Down Expand Up @@ -115,7 +115,8 @@ <R, T1> R just(ConnectionFunction1<T1, R> function, PipelineFunction1<T1, R> pip
Assert.notNull(function, "ConnectionFunction must not be null");
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");

return synchronizer.invoke(it -> function.apply(it, t1), it -> pipelineFunction.apply(it, t1));
return synchronizer.invoke(jedis -> function.apply(jedis, t1),
responseCommands -> pipelineFunction.apply(responseCommands, t1));
}

/**
Expand All @@ -133,7 +134,8 @@ <R, T1, T2> R just(ConnectionFunction2<T1, T2, R> function, PipelineFunction2<T1
Assert.notNull(function, "ConnectionFunction must not be null");
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");

return synchronizer.invoke(it -> function.apply(it, t1, t2), it -> pipelineFunction.apply(it, t1, t2));
return synchronizer.invoke(jedis -> function.apply(jedis, t1, t2),
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2));
}

/**
Expand All @@ -152,7 +154,8 @@ <R, T1, T2, T3> R just(ConnectionFunction3<T1, T2, T3, R> function, PipelineFunc
Assert.notNull(function, "ConnectionFunction must not be null");
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");

return synchronizer.invoke(it -> function.apply(it, t1, t2, t3), it -> pipelineFunction.apply(it, t1, t2, t3));
return synchronizer.invoke(jedis -> function.apply(jedis, t1, t2, t3),
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3));
}

/**
Expand All @@ -172,7 +175,7 @@ <R, T1, T2, T3, T4> R just(ConnectionFunction4<T1, T2, T3, T4, R> function,
Assert.notNull(function, "ConnectionFunction must not be null");
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");

return synchronizer.invoke(it -> function.apply(it, t1, t2, t3, t4),
return synchronizer.invoke(jedis -> function.apply(jedis, t1, t2, t3, t4),
it -> pipelineFunction.apply(it, t1, t2, t3, t4));
}

Expand All @@ -194,7 +197,7 @@ <R, T1, T2, T3, T4, T5> R just(ConnectionFunction5<T1, T2, T3, T4, T5, R> functi
Assert.notNull(function, "ConnectionFunction must not be null");
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");

return synchronizer.invoke(it -> function.apply(it, t1, t2, t3, t4, t5),
return synchronizer.invoke(jedis -> function.apply(jedis, t1, t2, t3, t4, t5),
it -> pipelineFunction.apply(it, t1, t2, t3, t4, t5));
}

Expand All @@ -217,8 +220,8 @@ <R, T1, T2, T3, T4, T5, T6> R just(ConnectionFunction6<T1, T2, T3, T4, T5, T6, R
Assert.notNull(function, "ConnectionFunction must not be null");
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");

return synchronizer.invoke(it -> function.apply(it, t1, t2, t3, t4, t5, t6),
it -> pipelineFunction.apply(it, t1, t2, t3, t4, t5, t6));
return synchronizer.invoke(jedis -> function.apply(jedis, t1, t2, t3, t4, t5, t6),
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3, t4, t5, t6));
}

/**
Expand Down Expand Up @@ -265,7 +268,7 @@ <R, T1> SingleInvocationSpec<R> from(ConnectionFunction1<T1, R> function, Pipeli
Assert.notNull(function, "ConnectionFunction must not be null");
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");

return from(it -> function.apply(it, t1), it -> pipelineFunction.apply(it, t1));
return from(jedis -> function.apply(jedis, t1), responseCommands -> pipelineFunction.apply(responseCommands, t1));
}

/**
Expand All @@ -283,7 +286,8 @@ <R, T1, T2> SingleInvocationSpec<R> from(ConnectionFunction2<T1, T2, R> function
Assert.notNull(function, "ConnectionFunction must not be null");
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");

return from(it -> function.apply(it, t1, t2), it -> pipelineFunction.apply(it, t1, t2));
return from(jedis -> function.apply(jedis, t1, t2),
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2));
}

/**
Expand All @@ -302,7 +306,8 @@ <R, T1, T2, T3> SingleInvocationSpec<R> from(ConnectionFunction3<T1, T2, T3, R>
Assert.notNull(function, "ConnectionFunction must not be null");
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");

return from(it -> function.apply(it, t1, t2, t3), it -> pipelineFunction.apply(it, t1, t2, t3));
return from(jedis -> function.apply(jedis, t1, t2, t3),
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3));
}

/**
Expand All @@ -322,7 +327,8 @@ <R, T1, T2, T3, T4> SingleInvocationSpec<R> from(ConnectionFunction4<T1, T2, T3,
Assert.notNull(function, "ConnectionFunction must not be null");
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");

return from(it -> function.apply(it, t1, t2, t3, t4), it -> pipelineFunction.apply(it, t1, t2, t3, t4));
return from(jedis -> function.apply(jedis, t1, t2, t3, t4),
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3, t4));
}

/**
Expand All @@ -343,7 +349,8 @@ <R, T1, T2, T3, T4, T5> SingleInvocationSpec<R> from(ConnectionFunction5<T1, T2,
Assert.notNull(function, "ConnectionFunction must not be null");
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");

return from(it -> function.apply(it, t1, t2, t3, t4, t5), it -> pipelineFunction.apply(it, t1, t2, t3, t4, t5));
return from(jedis -> function.apply(jedis, t1, t2, t3, t4, t5),
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3, t4, t5));
}

/**
Expand All @@ -365,8 +372,8 @@ <R, T1, T2, T3, T4, T5, T6> SingleInvocationSpec<R> from(ConnectionFunction6<T1,
Assert.notNull(function, "ConnectionFunction must not be null");
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");

return from(it -> function.apply(it, t1, t2, t3, t4, t5, t6),
it -> pipelineFunction.apply(it, t1, t2, t3, t4, t5, t6));
return from(jedis -> function.apply(jedis, t1, t2, t3, t4, t5, t6),
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3, t4, t5, t6));
}

/**
Expand Down Expand Up @@ -414,7 +421,8 @@ <R extends Collection<E>, E, T1> ManyInvocationSpec<E> fromMany(ConnectionFuncti
Assert.notNull(function, "ConnectionFunction must not be null");
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");

return fromMany(it -> function.apply(it, t1), it -> pipelineFunction.apply(it, t1));
return fromMany(jedis -> function.apply(jedis, t1),
responseCommands -> pipelineFunction.apply(responseCommands, t1));
}

/**
Expand All @@ -432,7 +440,8 @@ <R extends Collection<E>, E, T1, T2> ManyInvocationSpec<E> fromMany(ConnectionFu
Assert.notNull(function, "ConnectionFunction must not be null");
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");

return fromMany(it -> function.apply(it, t1, t2), it -> pipelineFunction.apply(it, t1, t2));
return fromMany(jedis -> function.apply(jedis, t1, t2),
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2));
}

/**
Expand All @@ -451,7 +460,8 @@ <R extends Collection<E>, E, T1, T2, T3> ManyInvocationSpec<E> fromMany(Connecti
Assert.notNull(function, "ConnectionFunction must not be null");
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");

return fromMany(it -> function.apply(it, t1, t2, t3), it -> pipelineFunction.apply(it, t1, t2, t3));
return fromMany(jedis -> function.apply(jedis, t1, t2, t3),
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3));
}

/**
Expand All @@ -472,7 +482,8 @@ <R extends Collection<E>, E, T1, T2, T3, T4> ManyInvocationSpec<E> fromMany(
Assert.notNull(function, "ConnectionFunction must not be null");
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");

return fromMany(it -> function.apply(it, t1, t2, t3, t4), it -> pipelineFunction.apply(it, t1, t2, t3, t4));
return fromMany(jedis -> function.apply(jedis, t1, t2, t3, t4),
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3, t4));
}

/**
Expand All @@ -494,7 +505,8 @@ <R extends Collection<E>, E, T1, T2, T3, T4, T5> ManyInvocationSpec<E> fromMany(
Assert.notNull(function, "ConnectionFunction must not be null");
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");

return fromMany(it -> function.apply(it, t1, t2, t3, t4, t5), it -> pipelineFunction.apply(it, t1, t2, t3, t4, t5));
return fromMany(jedis -> function.apply(jedis, t1, t2, t3, t4, t5),
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3, t4, t5));
}

/**
Expand All @@ -517,8 +529,8 @@ <R extends Collection<E>, E, T1, T2, T3, T4, T5, T6> ManyInvocationSpec<E> fromM
Assert.notNull(function, "ConnectionFunction must not be null");
Assert.notNull(pipelineFunction, "PipelineFunction must not be null");

return fromMany(it -> function.apply(it, t1, t2, t3, t4, t5, t6),
it -> pipelineFunction.apply(it, t1, t2, t3, t4, t5, t6));
return fromMany(jedis -> function.apply(jedis, t1, t2, t3, t4, t5, t6),
responseCommands -> pipelineFunction.apply(responseCommands, t1, t2, t3, t4, t5, t6));
}

/**
Expand Down

0 comments on commit fe6e65f

Please sign in to comment.