+ Optional<Resource> resource = Optional.ofNullable(typeToResource.get(typePrefix));
+ if (resource.isPresent()) {
+ // Make a copy of the Resource found in the mappings table.
+ return Optional.of(new Resource(resource.get()));
+ }
+ return resource;
+ }
+
+ public static Widget createWidgetFromType(String widgetType) throws XmlArtifactGenerationException {
+ Optional<Widget> widget = Optional.ofNullable(typeToWidget.get(widgetType));
+ if (widget.isPresent()) {
+ // Make a copy of the Widget found in the mappings table.
+ return new Widget(widget.get());
+ }
+ return null;
+ }
+
+ public static void setWidgetTypes(List<WidgetTypeConfig> types) {
+ WidgetType.clearElements();
+ for (WidgetTypeConfig type : types) {
+ if (type.type == null || type.name == null) {
+ throw new IllegalArgumentException("Incomplete widget type specified: " + type);
+ }
+ WidgetType widgetType = new WidgetType(type.type);
+ Widget widget = new Widget(widgetType, type.name, type.deleteFlag);
+ typeToWidget.put(type.type, widget);
+ }
+ WidgetType.validateElements();