|
@@ -1,32 +1,28 @@
|
|
|
package riomhaire.lti.core.business.builder;
|
|
|
|
|
|
-public class ActionBuilderFactory {
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
- private ActionBuilderBuilder launchContentBuilder = ()->new NopBuilder();
|
|
|
- private ActionBuilderBuilder processLTIMessageBuilder = ()->new NopBuilder();
|
|
|
- private ActionBuilderBuilder processOidcRequestBuilder= ()->new NopBuilder();
|
|
|
- private ActionBuilderBuilder selectDeepLinkContentBuilder = ()->new NopBuilder();
|
|
|
+@Slf4j
|
|
|
+public class ActionBuilderFactory {
|
|
|
+ private Map<Builder,ActionBuilderBuilder> builders = new HashMap<>();
|
|
|
|
|
|
- public ActionBuilderFactory(ActionBuilderBuilder launchContentBuilder, ActionBuilderBuilder processLTIMessageBuilder, ActionBuilderBuilder processOidcRequestBuilder, ActionBuilderBuilder selectDeepLinkContentBuilder) {
|
|
|
- this.launchContentBuilder = launchContentBuilder;
|
|
|
- this.processLTIMessageBuilder = processLTIMessageBuilder;
|
|
|
- this.processOidcRequestBuilder = processOidcRequestBuilder;
|
|
|
- this.selectDeepLinkContentBuilder = selectDeepLinkContentBuilder;
|
|
|
+ public ActionBuilderFactory(){
|
|
|
+ log.debug("Initializing ActionBuilderFactory");
|
|
|
+ setBuilder(Builder.ProcessOidcRequestBuilder,()->new ProcessOidcRequestBuilder());
|
|
|
+ setBuilder(Builder.ProcessLTIMessageBuilder,()->new ProcessLtiMessageBuilder());
|
|
|
+ setBuilder(Builder.LaunchContentBuilder,()->new LaunchContentBuilder());
|
|
|
}
|
|
|
- public ActionBuilderFactory(ActionBuilderBuilder launchContentBuilder){
|
|
|
- this.launchContentBuilder = launchContentBuilder;
|
|
|
- this.processLTIMessageBuilder = ()->new ProcessLtiMessageBuilder();
|
|
|
- this.processOidcRequestBuilder = ()->new ProcessOidcRequestBuilder();
|
|
|
- this.selectDeepLinkContentBuilder = ()->new NopBuilder();
|
|
|
|
|
|
+ public ActionBuilderFactory setBuilder(Builder builderName, ActionBuilderBuilder actionBuilder) {
|
|
|
+ builders.put(builderName,actionBuilder);
|
|
|
+ return this;
|
|
|
}
|
|
|
|
|
|
public ActionBuilder getBuilder(Builder name) {
|
|
|
- return switch (name) {
|
|
|
- case LaunchContentBuilder : yield launchContentBuilder.build();
|
|
|
- case ProcessLTIMessageBuilder: yield processLTIMessageBuilder.build();
|
|
|
- case ProcessOidcRequestBuilder: yield processOidcRequestBuilder.build();
|
|
|
- case SelectDeepLinkContentBuilder: yield selectDeepLinkContentBuilder.build();
|
|
|
- } ;
|
|
|
+ if( !builders.containsKey(name)) return new NopBuilder();
|
|
|
+ return builders.get(name).build();
|
|
|
}
|
|
|
}
|