@@ -97,37 +97,55 @@ public class ReactiveWrappers {
97
97
}
98
98
99
99
/**
100
- * Returns {@literal true} if {@code theClass} is a reactive wrapper type for single element emission.
100
+ * Returns {@literal true} if reactive support is available. More specifically, whether RxJava1/2 or Project Reactor
101
+ * libraries are on the class path.
101
102
*
102
- * @param theClass must not be {@literal null}.
103
- * @return {@literal true} if {@code theClass} is a reactive wrapper type for single element emission
103
+ * @return {@literal true} if reactive support is available.
104
104
*/
105
- public static boolean isSingleType (Class <?> theClass ) {
105
+ public static boolean isAvailable () {
106
+ return RXJAVA1_PRESENT || RXJAVA2_PRESENT || PROJECT_REACTOR_PRESENT ;
107
+ }
108
+
109
+ /**
110
+ * Returns {@literal true} if the {@code type} is a supported reactive wrapper type.
111
+ *
112
+ * @param type must not be {@literal null}.
113
+ * @return {@literal true} if the {@code type} is a supported reactive wrapper type.
114
+ */
115
+ public static boolean supports (Class <?> type ) {
116
+ return isSingleType (type ) || isMultiType (type );
117
+ }
118
+
119
+ /**
120
+ * Returns {@literal true} if {@code type} is a reactive wrapper type for single element emission.
121
+ *
122
+ * @param type must not be {@literal null}.
123
+ * @return {@literal true} if {@code type} is a reactive wrapper type for single element emission
124
+ */
125
+ public static boolean isSingleType (Class <?> type ) {
106
126
107
- Assert .notNull (theClass , "Class type must not be null!" );
127
+ Assert .notNull (type , "Class type must not be null!" );
108
128
109
- return isAssignable (SINGLE_TYPES , theClass );
129
+ return isAssignable (SINGLE_TYPES , type );
110
130
}
111
131
112
132
/**
113
- * Returns {@literal true} if {@code theClass} is a reactive wrapper type supporting emission of {@code 0..N}
114
- * elements.
133
+ * Returns {@literal true} if {@code type} is a reactive wrapper type supporting emission of {@code 0..N} elements.
115
134
*
116
- * @param theClass must not be {@literal null}.
117
- * @return {@literal true} if {@code theClass} is a reactive wrapper type supporting emission of {@code 0..N}
118
- * elements.
135
+ * @param type must not be {@literal null}.
136
+ * @return {@literal true} if {@code type} is a reactive wrapper type supporting emission of {@code 0..N} elements.
119
137
*/
120
- public static boolean isMultiType (Class <?> theClass ) {
138
+ public static boolean isMultiType (Class <?> type ) {
121
139
122
- Assert .notNull (theClass , "Class type must not be null!" );
140
+ Assert .notNull (type , "Class type must not be null!" );
123
141
124
142
// Prevent single-types with a multi-hierarchy supertype to be reported as multi type
125
143
// See Mono implements Publisher
126
- if (isSingleType (theClass )) {
144
+ if (isSingleType (type )) {
127
145
return false ;
128
146
}
129
147
130
- return isAssignable (MULTI_TYPES , theClass );
148
+ return isAssignable (MULTI_TYPES , type );
131
149
}
132
150
133
151
private static boolean isAssignable (Iterable <Class <?>> lhsTypes , Class <?> rhsType ) {
0 commit comments