Turned on checkstyle
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>spring-cloud-function-core</artifactId>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017 the original author or authors.
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,9 +26,8 @@ import reactor.core.publisher.Mono;
|
||||
* Wrapper for a {@link Consumer} implementation that converts a non-reactive consumer
|
||||
* into a reactive function.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*
|
||||
* @param <T> input type of target consumer
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class FluxConsumer<T>
|
||||
implements Function<Flux<T>, Mono<Void>>, FluxWrapper<Consumer<T>> {
|
||||
@@ -46,6 +45,7 @@ public class FluxConsumer<T>
|
||||
|
||||
@Override
|
||||
public Mono<Void> apply(Flux<T> input) {
|
||||
return input.doOnNext(consumer).then();
|
||||
return input.doOnNext(this.consumer).then();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017 the original author or authors.
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,19 +24,19 @@ import reactor.core.publisher.Flux;
|
||||
* {@link Function} implementation that wraps a target Function so that the target's
|
||||
* simple input and output types will be wrapped as {@link Flux} instances.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*
|
||||
* @param <T> input type of target function
|
||||
* @param <R> output type of target function
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class FluxFunction<T, R> implements Function<Flux<T>, Flux<R>>, FluxWrapper<Function<T, R>> {
|
||||
public class FluxFunction<T, R>
|
||||
implements Function<Flux<T>, Flux<R>>, FluxWrapper<Function<T, R>> {
|
||||
|
||||
private final Function<T, R> function;
|
||||
|
||||
public FluxFunction(Function<T, R> function) {
|
||||
this.function = function;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Function<T, R> getTarget() {
|
||||
return this.function;
|
||||
@@ -46,4 +46,5 @@ public class FluxFunction<T, R> implements Function<Flux<T>, Flux<R>>, FluxWrapp
|
||||
public Flux<R> apply(Flux<T> input) {
|
||||
return input.map(i -> this.function.apply(i));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017 the original author or authors.
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,17 +23,16 @@ import java.util.stream.Stream;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
/**
|
||||
* {@link Supplier} implementation that wraps a target Supplier so that the
|
||||
* target's simple output type will be wrapped in a {@link Flux} instance.
|
||||
* If a {@link Duration} is provided, the Flux will produce output
|
||||
* periodically, invoking the target Supplier's {@code get} method at each
|
||||
* interval. If no Duration is provided, the target will be invoked only once.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* {@link Supplier} implementation that wraps a target Supplier so that the target's
|
||||
* simple output type will be wrapped in a {@link Flux} instance. If a {@link Duration} is
|
||||
* provided, the Flux will produce output periodically, invoking the target Supplier's
|
||||
* {@code get} method at each interval. If no Duration is provided, the target will be
|
||||
* invoked only once.
|
||||
*
|
||||
* @param <T> output type of target supplier
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class FluxSupplier<T> implements Supplier<Flux<T>>, FluxWrapper<Supplier<T>> {
|
||||
public class FluxSupplier<T> implements Supplier<Flux<T>>, FluxWrapper<Supplier<T>> {
|
||||
|
||||
private final Supplier<T> supplier;
|
||||
|
||||
@@ -42,7 +41,7 @@ public class FluxSupplier<T> implements Supplier<Flux<T>>, FluxWrapper<Supplier<
|
||||
public FluxSupplier(Supplier<T> supplier) {
|
||||
this(supplier, null);
|
||||
}
|
||||
|
||||
|
||||
public FluxSupplier(Supplier<T> supplier, Duration period) {
|
||||
this.supplier = supplier;
|
||||
this.period = period;
|
||||
@@ -52,12 +51,12 @@ public class FluxSupplier<T> implements Supplier<Flux<T>>, FluxWrapper<Supplier<
|
||||
public Supplier<T> getTarget() {
|
||||
return this.supplier;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public Flux<T> get() {
|
||||
if (this.period != null) {
|
||||
return Flux.interval(this.period).map(i->this.supplier.get());
|
||||
return Flux.interval(this.period).map(i -> this.supplier.get());
|
||||
}
|
||||
Object result = this.supplier.get();
|
||||
if (result instanceof Stream) {
|
||||
@@ -65,4 +64,5 @@ public class FluxSupplier<T> implements Supplier<Flux<T>>, FluxWrapper<Supplier<
|
||||
}
|
||||
return Flux.just((T) result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018 the original author or authors.
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,15 +22,15 @@ import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* Marker wrapper for target Function<Flux, Mono>
|
||||
* Marker wrapper for target Function<Flux, Mono>.
|
||||
*
|
||||
* @param <I> type of {@link Flux} input of the target function
|
||||
* @param <O> type of {@link Mono} output of the target function
|
||||
* @author Oleg Zhurakousky
|
||||
* @since 2.0
|
||||
*
|
||||
* @param <T> type of {@link Flux} input of the target function
|
||||
* @param <R> type of {@link Mono} output of the target function
|
||||
*/
|
||||
public class FluxToMonoFunction<I,O> implements Function<Flux<I>, Mono<O>>, FluxWrapper<Function<Flux<I>, Mono<O>>> {
|
||||
public class FluxToMonoFunction<I, O>
|
||||
implements Function<Flux<I>, Mono<O>>, FluxWrapper<Function<Flux<I>, Mono<O>>> {
|
||||
|
||||
private final Function<Flux<I>, Mono<O>> function;
|
||||
|
||||
@@ -43,11 +43,12 @@ public class FluxToMonoFunction<I,O> implements Function<Flux<I>, Mono<O>>, Flux
|
||||
|
||||
@Override
|
||||
public Function<Flux<I>, Mono<O>> getTarget() {
|
||||
return function;
|
||||
return this.function;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<O> apply(Flux<I> input) {
|
||||
return function.apply(input);
|
||||
return this.function.apply(input);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2017 the original author or authors.
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,11 +17,11 @@
|
||||
package org.springframework.cloud.function.core;
|
||||
|
||||
/**
|
||||
* @param <T> target type
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public interface FluxWrapper<T> {
|
||||
|
||||
|
||||
T getTarget();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2017 the original author or authors.
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,9 +19,8 @@ package org.springframework.cloud.function.core;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* @param <F> target type
|
||||
* @author Dave Syer
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public interface FunctionFactoryMetadata<F> {
|
||||
|
||||
@@ -29,4 +28,4 @@ public interface FunctionFactoryMetadata<F> {
|
||||
|
||||
F getTarget();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2017 the original author or authors.
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,4 +23,5 @@ package org.springframework.cloud.function.core;
|
||||
public interface Isolated {
|
||||
|
||||
ClassLoader getClassLoader();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2017 the original author or authors.
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,12 +21,13 @@ import java.util.function.Consumer;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* @param <T> type to consume
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class IsolatedConsumer<T> implements Consumer<T>, Isolated {
|
||||
|
||||
private final Consumer<T> consumer;
|
||||
|
||||
private final ClassLoader classLoader;
|
||||
|
||||
public IsolatedConsumer(Consumer<T> consumer) {
|
||||
@@ -44,7 +45,7 @@ public class IsolatedConsumer<T> implements Consumer<T>, Isolated {
|
||||
ClassLoader context = ClassUtils
|
||||
.overrideThreadContextClassLoader(this.classLoader);
|
||||
try {
|
||||
consumer.accept(item);
|
||||
this.consumer.accept(item);
|
||||
}
|
||||
finally {
|
||||
ClassUtils.overrideThreadContextClassLoader(context);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2017 the original author or authors.
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,12 +21,14 @@ import java.util.function.Function;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* @param <S> input type
|
||||
* @param <T> output type
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class IsolatedFunction<S, T> implements Function<S, T>, Isolated {
|
||||
|
||||
private final Function<S, T> function;
|
||||
|
||||
private final ClassLoader classLoader;
|
||||
|
||||
public IsolatedFunction(Function<S, T> function) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2017 the original author or authors.
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,12 +21,13 @@ import java.util.function.Supplier;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* @param <T> supplied type
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class IsolatedSupplier<T> implements Supplier<T>, Isolated {
|
||||
|
||||
private final Supplier<T> supplier;
|
||||
|
||||
private final ClassLoader classLoader;
|
||||
|
||||
public IsolatedSupplier(Supplier<T> supplier) {
|
||||
@@ -44,7 +45,7 @@ public class IsolatedSupplier<T> implements Supplier<T>, Isolated {
|
||||
ClassLoader context = ClassUtils
|
||||
.overrideThreadContextClassLoader(this.classLoader);
|
||||
try {
|
||||
return supplier.get();
|
||||
return this.supplier.get();
|
||||
}
|
||||
finally {
|
||||
ClassUtils.overrideThreadContextClassLoader(context);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018 the original author or authors.
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,21 +22,20 @@ import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* Marker wrapper for target Function<Mono, Flux>
|
||||
* Marker wrapper for target Function<Mono, Flux>.
|
||||
*
|
||||
* @param <I> type of {@link Mono} input of the target function
|
||||
* @param <O> type of {@link Flux} output of the target function
|
||||
* @author Oleg Zhurakousky
|
||||
* @since 2.0
|
||||
*
|
||||
* @param <T> type of {@link Mono} input of the target function
|
||||
* @param <R> type of {@link Flux} output of the target function
|
||||
*/
|
||||
public class MonoToFluxFunction<I,O> implements Function<Mono<I>, Flux<O>>, FluxWrapper<Function<Mono<I>, Flux<O>>> {
|
||||
public class MonoToFluxFunction<I, O>
|
||||
implements Function<Mono<I>, Flux<O>>, FluxWrapper<Function<Mono<I>, Flux<O>>> {
|
||||
|
||||
private final Function<Mono<I>, Flux<O>> function;
|
||||
|
||||
/**
|
||||
* @param function target function
|
||||
* @param names name(s) of the target function (optional)
|
||||
*/
|
||||
public MonoToFluxFunction(Function<Mono<I>, Flux<O>> function) {
|
||||
this.function = function;
|
||||
@@ -44,11 +43,12 @@ public class MonoToFluxFunction<I,O> implements Function<Mono<I>, Flux<O>>, Flux
|
||||
|
||||
@Override
|
||||
public Function<Mono<I>, Flux<O>> getTarget() {
|
||||
return function;
|
||||
return this.function;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<O> apply(Mono<I> input) {
|
||||
return function.apply(input);
|
||||
return this.function.apply(input);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user