@@ -56,7 +56,7 @@ private BackgroundFunctionExecutor(FunctionExecutor<?> functionExecutor) {
56
56
this .functionExecutor = functionExecutor ;
57
57
}
58
58
59
- enum FunctionKind {
59
+ private enum FunctionKind {
60
60
BACKGROUND (BackgroundFunction .class ),
61
61
RAW_BACKGROUND (RawBackgroundFunction .class ),
62
62
CLOUD_EVENTS (ExperimentalCloudEventsFunction .class );
@@ -69,11 +69,21 @@ enum FunctionKind {
69
69
this .functionClass = functionClass ;
70
70
}
71
71
72
+ /** Returns the {@link FunctionKind} that the given class implements, if any. */
72
73
static Optional <FunctionKind > forClass (Class <?> functionClass ) {
73
74
return VALUES .stream ().filter (v -> v .functionClass .isAssignableFrom (functionClass )).findFirst ();
74
75
}
75
76
}
76
77
78
+ /**
79
+ * Optionally makes a {@link BackgroundFunctionExecutor} for the given class, if it implements one
80
+ * of {@link BackgroundFunction}, {@link RawBackgroundFunction}, or
81
+ * {@link ExperimentalCloudEventsFunction}. Otherwise returns {@link Optional#empty()}.
82
+ *
83
+ * @param functionClass the class of a possible background function implementation.
84
+ * @throws RuntimeException if the given class does implement one of the required interfaces, but we are
85
+ * unable to construct an instance using its no-arg constructor.
86
+ */
77
87
public static Optional <BackgroundFunctionExecutor > maybeForClass (Class <?> functionClass ) {
78
88
Optional <FunctionKind > maybeFunctionKind = FunctionKind .forClass (functionClass );
79
89
if (!maybeFunctionKind .isPresent ()) {
@@ -83,11 +93,12 @@ public static Optional<BackgroundFunctionExecutor> maybeForClass(Class<?> functi
83
93
}
84
94
85
95
/**
86
- * Makes a {@link HttpFunctionExecutor } for the given class.
96
+ * Makes a {@link BackgroundFunctionExecutor } for the given class.
87
97
*
88
98
* @throws RuntimeException if either the class does not implement one of
89
- * {@link BackgroundFunction} or {@link RawBackgroundFunction},
90
- * or we are unable to construct an instance using its no-arg constructor.
99
+ * {@link BackgroundFunction}, {@link RawBackgroundFunction}, or
100
+ * {@link ExperimentalCloudEventsFunction}; or we are unable to construct an instance using its no-arg
101
+ * constructor.
91
102
*/
92
103
public static BackgroundFunctionExecutor forClass (Class <?> functionClass ) {
93
104
Optional <FunctionKind > maybeFunctionKind = FunctionKind .forClass (functionClass );
0 commit comments