Skip to content

Commit

Permalink
Make compareCollections return an extension of Collection rather than…
Browse files Browse the repository at this point in the history
… Collection itself
  • Loading branch information
martinvisser committed Nov 15, 2023
1 parent d600f12 commit cd21127
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/java/io/github/rabobank/shadow_tool/ShadowFlow.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@ public T compare(final Supplier<T> currentFlow, final Supplier<T> newFlow) {
* @param newFlow A supplier that return the result of the new service call
* that you want to start using.
* @param clazz The model that the current and new flow should be mapped to for comparison.
* @param <C> The type of collection to compare, for example a List
* @return This will always return the value of currentFlow supplier.
*/
public Collection<T> compareCollections(final Supplier<Collection<T>> currentFlow, final Supplier<Collection<T>> newFlow, final Class<T> clazz) {
public <C extends Collection<T>> C compareCollections(final Supplier<C> currentFlow, final Supplier<C> newFlow, final Class<T> clazz) {
final var currentFlowResponse = currentFlow.get();
doShadowFlow(() -> javers.compareCollections(currentFlowResponse, newFlow.get(), clazz));

Expand Down Expand Up @@ -157,9 +158,10 @@ public Mono<T> compare(final Mono<T> currentFlow, final Mono<T> newFlow) {
* @param newFlow A mono that returns the result of the new service call
* that you want to start using.
* @param clazz The model that the current and new flow should be mapped to for comparison.
* @param <C> The type of collection to compare, for example a List
* @return This will always return the mono of currentFlow.
*/
public Mono<Collection<T>> compareCollections(final Mono<? extends Collection<T>> currentFlow, final Mono<? extends Collection<T>> newFlow, final Class<T> clazz) {
public <C extends Collection<T>> Mono<C> compareCollections(final Mono<? extends C> currentFlow, final Mono<? extends C> newFlow, final Class<T> clazz) {
final var callNewFlow = shouldCallNewFlow();

return Mono.deferContextual(contextView ->
Expand Down Expand Up @@ -339,7 +341,7 @@ public ShadowFlow<T> build() {
private int validatePercentage(final int percentage) {
if (percentage < ZERO || percentage > HUNDRED) {
logger.error("Invalid percentage! Must be within the range of 0 and 100. Got {}. " +
"The shadow flow will be effectively disabled by setting it to 0%.", percentage);
"The shadow flow will be effectively disabled by setting it to 0%.", percentage);
return ZERO;
}

Expand Down

0 comments on commit cd21127

Please sign in to comment.