Skip to content

Commit 3e096ce

Browse files
committed
Improve javadoc on reactive classes
Ensure type-level Javadoc in every class, comply with guidelines for 80 char on Javadoc, and minor polish.
1 parent 7a0c242 commit 3e096ce

File tree

62 files changed

+255
-161
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+255
-161
lines changed

spring-core/src/main/java/org/springframework/core/codec/AbstractDecoder.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import org.springframework.util.MimeType;
2929

3030
/**
31+
* Abstract base class for {@link Decoder} implementations.
32+
*
3133
* @author Sebastien Deleuze
3234
* @author Arjen Poutsma
3335
* @since 5.0
@@ -36,6 +38,7 @@ public abstract class AbstractDecoder<T> implements Decoder<T> {
3638

3739
private List<MimeType> decodableMimeTypes = Collections.emptyList();
3840

41+
3942
protected AbstractDecoder(MimeType... supportedMimeTypes) {
4043
this.decodableMimeTypes = Arrays.asList(supportedMimeTypes);
4144
}
@@ -51,12 +54,14 @@ public boolean canDecode(ResolvableType elementType, MimeType mimeType, Object..
5154
if (mimeType == null) {
5255
return true;
5356
}
54-
return this.decodableMimeTypes.stream().
55-
anyMatch(mt -> mt.isCompatibleWith(mimeType));
57+
return this.decodableMimeTypes.stream().anyMatch(m -> m.isCompatibleWith(mimeType));
5658
}
5759

5860
@Override
59-
public Mono<T> decodeToMono(Publisher<DataBuffer> inputStream, ResolvableType elementType, MimeType mimeType, Object... hints) {
61+
public Mono<T> decodeToMono(Publisher<DataBuffer> inputStream, ResolvableType elementType,
62+
MimeType mimeType, Object... hints) {
63+
6064
throw new UnsupportedOperationException();
6165
}
66+
6267
}

spring-core/src/main/java/org/springframework/core/codec/AbstractEncoder.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import org.springframework.util.MimeType;
2525

2626
/**
27+
* Abstract base class for {@link Decoder} implementations.
28+
*
2729
* @author Sebastien Deleuze
2830
* @author Arjen Poutsma
2931
* @since 5.0
@@ -32,6 +34,7 @@ public abstract class AbstractEncoder<T> implements Encoder<T> {
3234

3335
private List<MimeType> encodableMimeTypes = Collections.emptyList();
3436

37+
3538
protected AbstractEncoder(MimeType... supportedMimeTypes) {
3639
this.encodableMimeTypes = Arrays.asList(supportedMimeTypes);
3740
}
@@ -47,8 +50,7 @@ public boolean canEncode(ResolvableType elementType, MimeType mimeType, Object..
4750
if (mimeType == null) {
4851
return true;
4952
}
50-
return this.encodableMimeTypes.stream().
51-
anyMatch(mt -> mt.isCompatibleWith(mimeType));
53+
return this.encodableMimeTypes.stream().anyMatch(m -> m.isCompatibleWith(mimeType));
5254
}
5355

5456
}

spring-core/src/main/java/org/springframework/core/codec/AbstractSingleValueEncoder.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,25 @@
2525
import org.springframework.util.MimeType;
2626

2727
/**
28-
* Abstract base class for {@link org.springframework.core.codec.Encoder} classes that
29-
* can only deal with a single value.
28+
* Abstract base class for {@link org.springframework.core.codec.Encoder}
29+
* classes that can only deal with a single value.
30+
*
3031
* @author Arjen Poutsma
3132
* @since 5.0
3233
*/
3334
public abstract class AbstractSingleValueEncoder<T> extends AbstractEncoder<T> {
3435

36+
3537
public AbstractSingleValueEncoder(MimeType... supportedMimeTypes) {
3638
super(supportedMimeTypes);
3739
}
3840

41+
3942
@Override
4043
public final Flux<DataBuffer> encode(Publisher<? extends T> inputStream,
4144
DataBufferFactory bufferFactory, ResolvableType elementType, MimeType mimeType,
4245
Object... hints) {
46+
4347
return Flux.from(inputStream).
4448
take(1).
4549
concatMap(t -> {
@@ -53,7 +57,7 @@ public final Flux<DataBuffer> encode(Publisher<? extends T> inputStream,
5357
}
5458

5559
/**
56-
* Encodes {@code T} to an output {@link DataBuffer} stream.
60+
* Encode {@code T} to an output {@link DataBuffer} stream.
5761
* @param t the value to process
5862
* @param dataBufferFactory a buffer factory used to create the output
5963
* @param type the stream element type to process
@@ -65,5 +69,4 @@ public final Flux<DataBuffer> encode(Publisher<? extends T> inputStream,
6569
protected abstract Flux<DataBuffer> encode(T t, DataBufferFactory dataBufferFactory,
6670
ResolvableType type, MimeType mimeType, Object... hints) throws Exception;
6771

68-
6972
}

spring-core/src/main/java/org/springframework/core/codec/ByteBufferDecoder.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import org.springframework.util.MimeTypeUtils;
2929

3030
/**
31+
* Decoder for {@link ByteBuffer}s.
32+
*
3133
* @author Sebastien Deleuze
3234
* @author Arjen Poutsma
3335
* @since 5.0
@@ -49,6 +51,7 @@ public boolean canDecode(ResolvableType elementType, MimeType mimeType, Object..
4951
@Override
5052
public Flux<ByteBuffer> decode(Publisher<DataBuffer> inputStream, ResolvableType elementType,
5153
MimeType mimeType, Object... hints) {
54+
5255
return Flux.from(inputStream).map((dataBuffer) -> {
5356
ByteBuffer copy = ByteBuffer.allocate(dataBuffer.readableByteCount());
5457
copy.put(dataBuffer.asByteBuffer());

spring-core/src/main/java/org/springframework/core/codec/ByteBufferEncoder.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@
2828
import org.springframework.util.MimeTypeUtils;
2929

3030
/**
31+
* Encoder for {@link ByteBuffer}s.
32+
*
3133
* @author Sebastien Deleuze
3234
* @since 5.0
3335
*/
3436
public class ByteBufferEncoder extends AbstractEncoder<ByteBuffer> {
3537

38+
3639
public ByteBufferEncoder() {
3740
super(MimeTypeUtils.ALL);
3841
}

spring-core/src/main/java/org/springframework/core/codec/ResourceDecoder.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,19 @@
3232
import org.springframework.util.MimeTypeUtils;
3333

3434
/**
35-
* A decoder for {@link Resource}s.
35+
* Decoder for {@link Resource}s.
3636
*
3737
* @author Arjen Poutsma
3838
* @since 5.0
3939
*/
4040
public class ResourceDecoder extends AbstractDecoder<Resource> {
4141

42+
4243
public ResourceDecoder() {
4344
super(MimeTypeUtils.ALL);
4445
}
4546

47+
4648
@Override
4749
public boolean canDecode(ResolvableType elementType, MimeType mimeType, Object... hints) {
4850
Class<?> clazz = elementType.getRawClass();
@@ -54,6 +56,7 @@ public boolean canDecode(ResolvableType elementType, MimeType mimeType, Object..
5456
@Override
5557
public Flux<Resource> decode(Publisher<DataBuffer> inputStream, ResolvableType elementType,
5658
MimeType mimeType, Object... hints) {
59+
5760
Class<?> clazz = elementType.getRawClass();
5861

5962
Mono<byte[]> byteArray = Flux.from(inputStream).
@@ -67,17 +70,13 @@ public Flux<Resource> decode(Publisher<DataBuffer> inputStream, ResolvableType e
6770

6871

6972
if (InputStreamResource.class.equals(clazz)) {
70-
return Flux.from(byteArray.
71-
map(ByteArrayInputStream::new).
72-
map(InputStreamResource::new));
73+
return Flux.from(byteArray.map(ByteArrayInputStream::new).map(InputStreamResource::new));
7374
}
7475
else if (clazz.isAssignableFrom(ByteArrayResource.class)) {
75-
return Flux.from(byteArray.
76-
map(ByteArrayResource::new));
76+
return Flux.from(byteArray.map(ByteArrayResource::new));
7777
}
7878
else {
79-
return Flux.error(new IllegalStateException(
80-
"Unsupported resource class: " + clazz));
79+
return Flux.error(new IllegalStateException("Unsupported resource class: " + clazz));
8180
}
8281
}
8382
}

spring-core/src/main/java/org/springframework/core/codec/ResourceEncoder.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,19 @@
3232
import org.springframework.util.StreamUtils;
3333

3434
/**
35-
* An encoder for {@link Resource}s.
35+
* Encoder for {@link Resource}s.
36+
*
3637
* @author Arjen Poutsma
3738
* @since 5.0
3839
*/
3940
public class ResourceEncoder extends AbstractSingleValueEncoder<Resource> {
4041

4142
public static final int DEFAULT_BUFFER_SIZE = StreamUtils.BUFFER_SIZE;
4243

44+
4345
private final int bufferSize;
4446

47+
4548
public ResourceEncoder() {
4649
this(DEFAULT_BUFFER_SIZE);
4750
}
@@ -52,17 +55,17 @@ public ResourceEncoder(int bufferSize) {
5255
this.bufferSize = bufferSize;
5356
}
5457

58+
5559
@Override
5660
public boolean canEncode(ResolvableType elementType, MimeType mimeType, Object... hints) {
5761
Class<?> clazz = elementType.getRawClass();
58-
return (super.canEncode(elementType, mimeType, hints) &&
59-
Resource.class.isAssignableFrom(clazz));
62+
return (super.canEncode(elementType, mimeType, hints) && Resource.class.isAssignableFrom(clazz));
6063
}
6164

6265
@Override
63-
protected Flux<DataBuffer> encode(Resource resource,
64-
DataBufferFactory dataBufferFactory,
66+
protected Flux<DataBuffer> encode(Resource resource, DataBufferFactory dataBufferFactory,
6567
ResolvableType type, MimeType mimeType, Object... hints) throws IOException {
68+
6669
InputStream is = resource.getInputStream();
6770
return DataBufferUtils.read(is, dataBufferFactory, bufferSize);
6871
}

spring-core/src/main/java/org/springframework/core/codec/StringEncoder.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class StringEncoder extends AbstractEncoder<String> {
3838

3939
public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
4040

41+
4142
public StringEncoder() {
4243
super(new MimeType("text", "plain", DEFAULT_CHARSET));
4344
}
@@ -51,8 +52,9 @@ public boolean canEncode(ResolvableType elementType, MimeType mimeType, Object..
5152

5253
@Override
5354
public Flux<DataBuffer> encode(Publisher<? extends String> inputStream,
54-
DataBufferFactory bufferFactory, ResolvableType elementType, MimeType mimeType,
55-
Object... hints) {
55+
DataBufferFactory bufferFactory, ResolvableType elementType,
56+
MimeType mimeType, Object... hints) {
57+
5658
Charset charset;
5759
if (mimeType != null && mimeType.getCharset() != null) {
5860
charset = mimeType.getCharset();

spring-core/src/main/java/org/springframework/core/convert/support/MonoToCompletableFutureConverter.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@
2727
import org.springframework.core.convert.converter.GenericConverter;
2828

2929
/**
30+
* Converter to adapt {@link CompletableFuture} to Reactive Streams and
31+
* Reactor {@link Mono}.
32+
*
3033
* @author Sebastien Deleuze
3134
* @since 5.0
3235
*/
3336
public class MonoToCompletableFutureConverter implements GenericConverter {
3437

38+
3539
@Override
3640
public Set<GenericConverter.ConvertiblePair> getConvertibleTypes() {
3741
Set<GenericConverter.ConvertiblePair> pairs = new LinkedHashSet<>(2);
@@ -40,6 +44,7 @@ public Set<GenericConverter.ConvertiblePair> getConvertibleTypes() {
4044
return pairs;
4145
}
4246

47+
4348
@Override
4449
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
4550
if (source == null) {

spring-core/src/main/java/org/springframework/core/convert/support/ReactorToRxJava1Converter.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
import org.springframework.core.convert.converter.GenericConverter;
3232

3333
/**
34+
* Converter to adapt RxJava1 {@link Observable}, {@link Single}, and
35+
* {@link Completable} to Reactive Streams and Reactor types.
36+
*
3437
* @author Stephane Maldini
3538
* @author Sebastien Deleuze
3639
* @since 5.0

0 commit comments

Comments
 (0)