1
1
/*
2
- * Copyright 2002-2018 the original author or authors.
2
+ * Copyright 2002-2019 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
23
23
24
24
/**
25
25
* Describes the semantics of a reactive type including boolean checks for
26
- * {@link #isMultiValue()}, {@link #supportsEmpty ()}, and {@link #isNoValue ()}.
26
+ * {@link #isMultiValue()}, {@link #isNoValue ()}, and {@link #supportsEmpty ()}.
27
27
*
28
28
* @author Rossen Stoyanchev
29
29
* @since 5.0
@@ -32,25 +32,25 @@ public final class ReactiveTypeDescriptor {
32
32
33
33
private final Class <?> reactiveType ;
34
34
35
- @ Nullable
36
- private final Supplier <?> emptyValueSupplier ;
37
-
38
35
private final boolean multiValue ;
39
36
40
37
private final boolean noValue ;
41
38
39
+ @ Nullable
40
+ private final Supplier <?> emptyValueSupplier ;
41
+
42
42
43
43
/**
44
44
* Private constructor. See static factory methods.
45
45
*/
46
- private ReactiveTypeDescriptor (Class <?> reactiveType , @ Nullable Supplier <?> emptySupplier ,
47
- boolean multiValue , boolean noValue ) {
46
+ private ReactiveTypeDescriptor (Class <?> reactiveType , boolean multiValue , boolean noValue ,
47
+ @ Nullable Supplier <?> emptySupplier ) {
48
48
49
49
Assert .notNull (reactiveType , "'reactiveType' must not be null" );
50
50
this .reactiveType = reactiveType ;
51
- this .emptyValueSupplier = emptySupplier ;
52
51
this .multiValue = multiValue ;
53
52
this .noValue = noValue ;
53
+ this .emptyValueSupplier = emptySupplier ;
54
54
}
55
55
56
56
@@ -71,13 +71,6 @@ public boolean isMultiValue() {
71
71
return this .multiValue ;
72
72
}
73
73
74
- /**
75
- * Return {@code true} if the reactive type can complete with no values.
76
- */
77
- public boolean supportsEmpty () {
78
- return (this .emptyValueSupplier != null );
79
- }
80
-
81
74
/**
82
75
* Return {@code true} if the reactive type does not produce any values and
83
76
* only provides completion and error signals.
@@ -86,6 +79,13 @@ public boolean isNoValue() {
86
79
return this .noValue ;
87
80
}
88
81
82
+ /**
83
+ * Return {@code true} if the reactive type can complete with no values.
84
+ */
85
+ public boolean supportsEmpty () {
86
+ return (this .emptyValueSupplier != null );
87
+ }
88
+
89
89
/**
90
90
* Return an empty-value instance for the underlying reactive or async type.
91
91
* Use of this type implies {@link #supportsEmpty()} is true.
@@ -119,7 +119,7 @@ public int hashCode() {
119
119
* @param emptySupplier a supplier of an empty-value instance of the reactive type
120
120
*/
121
121
public static ReactiveTypeDescriptor multiValue (Class <?> type , Supplier <?> emptySupplier ) {
122
- return new ReactiveTypeDescriptor (type , emptySupplier , true , false );
122
+ return new ReactiveTypeDescriptor (type , true , false , emptySupplier );
123
123
}
124
124
125
125
/**
@@ -128,15 +128,15 @@ public static ReactiveTypeDescriptor multiValue(Class<?> type, Supplier<?> empty
128
128
* @param emptySupplier a supplier of an empty-value instance of the reactive type
129
129
*/
130
130
public static ReactiveTypeDescriptor singleOptionalValue (Class <?> type , Supplier <?> emptySupplier ) {
131
- return new ReactiveTypeDescriptor (type , emptySupplier , false , false );
131
+ return new ReactiveTypeDescriptor (type , false , false , emptySupplier );
132
132
}
133
133
134
134
/**
135
135
* Descriptor for a reactive type that must produce 1 value to complete.
136
136
* @param type the reactive type
137
137
*/
138
138
public static ReactiveTypeDescriptor singleRequiredValue (Class <?> type ) {
139
- return new ReactiveTypeDescriptor (type , null , false , false );
139
+ return new ReactiveTypeDescriptor (type , false , false , null );
140
140
}
141
141
142
142
/**
@@ -145,7 +145,7 @@ public static ReactiveTypeDescriptor singleRequiredValue(Class<?> type) {
145
145
* @param emptySupplier a supplier of an empty-value instance of the reactive type
146
146
*/
147
147
public static ReactiveTypeDescriptor noValue (Class <?> type , Supplier <?> emptySupplier ) {
148
- return new ReactiveTypeDescriptor (type , emptySupplier , false , true );
148
+ return new ReactiveTypeDescriptor (type , false , true , emptySupplier );
149
149
}
150
150
151
151
}
0 commit comments