From 7b8c54fcc6df74d5ed56e29877bbcb1653a06599 Mon Sep 17 00:00:00 2001 From: Brooks Johnson Date: Fri, 20 Jan 2023 14:43:07 -0500 Subject: [PATCH] bridge pattern completed --- .../default/classes/Bridge/BlogFramework.cls | 19 ++++++++ .../classes/Bridge/BlogFramework.cls-meta.xml | 5 +++ .../default/classes/Bridge/CMSFramework.cls | 15 +++++++ .../classes/Bridge/CMSFramework.cls-meta.xml | 5 +++ .../main/default/classes/Bridge/ITheme.cls | 11 +++++ .../classes/Bridge/ITheme.cls-meta.xml | 5 +++ .../classes/Bridge/Theme_WhiteBlue.cls | 27 ++++++++++++ .../Bridge/Theme_WhiteBlue.cls-meta.xml | 5 +++ .../classes/Bridge/Theme_WhiteGreen.cls | 27 ++++++++++++ .../Bridge/Theme_WhiteGreen.cls-meta.xml | 5 +++ .../default/classes/Bridge/WebFramework.cls | 43 +++++++++++++++++++ .../classes/Bridge/WebFramework.cls-meta.xml | 5 +++ .../default/classes/Builder/UserBuilder.cls | 1 - package-lock.json | 21 +++++++++ 14 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 force-app/main/default/classes/Bridge/BlogFramework.cls create mode 100644 force-app/main/default/classes/Bridge/BlogFramework.cls-meta.xml create mode 100644 force-app/main/default/classes/Bridge/CMSFramework.cls create mode 100644 force-app/main/default/classes/Bridge/CMSFramework.cls-meta.xml create mode 100644 force-app/main/default/classes/Bridge/ITheme.cls create mode 100644 force-app/main/default/classes/Bridge/ITheme.cls-meta.xml create mode 100644 force-app/main/default/classes/Bridge/Theme_WhiteBlue.cls create mode 100644 force-app/main/default/classes/Bridge/Theme_WhiteBlue.cls-meta.xml create mode 100644 force-app/main/default/classes/Bridge/Theme_WhiteGreen.cls create mode 100644 force-app/main/default/classes/Bridge/Theme_WhiteGreen.cls-meta.xml create mode 100644 force-app/main/default/classes/Bridge/WebFramework.cls create mode 100644 force-app/main/default/classes/Bridge/WebFramework.cls-meta.xml diff --git a/force-app/main/default/classes/Bridge/BlogFramework.cls b/force-app/main/default/classes/Bridge/BlogFramework.cls new file mode 100644 index 0000000..8206f60 --- /dev/null +++ b/force-app/main/default/classes/Bridge/BlogFramework.cls @@ -0,0 +1,19 @@ +/** + * Created by bjohnson on 1/20/23. + */ + +public with sharing class BlogFramework extends WebFramework { + + public BlogFramework(ITheme theme){ + super(theme); + } + + public override void capability() { + System.debug('This app does not support menu and it is not styled'); + } + + + public override void showMenuBody() { + theme.styleContent(); + } +} \ No newline at end of file diff --git a/force-app/main/default/classes/Bridge/BlogFramework.cls-meta.xml b/force-app/main/default/classes/Bridge/BlogFramework.cls-meta.xml new file mode 100644 index 0000000..dd61d1f --- /dev/null +++ b/force-app/main/default/classes/Bridge/BlogFramework.cls-meta.xml @@ -0,0 +1,5 @@ + + + 52.0 + Active + diff --git a/force-app/main/default/classes/Bridge/CMSFramework.cls b/force-app/main/default/classes/Bridge/CMSFramework.cls new file mode 100644 index 0000000..9abb3cb --- /dev/null +++ b/force-app/main/default/classes/Bridge/CMSFramework.cls @@ -0,0 +1,15 @@ +/** + * Created by bjohnson on 1/20/23. + */ + +public with sharing class CMSFramework extends WebFramework { + + public CMSFramework(ITheme theme) { + super(theme); + } + + public override void capability() { + System.debug('This is a CMS Framework and supports workflow to ' + + 'publish public content'); + } +} \ No newline at end of file diff --git a/force-app/main/default/classes/Bridge/CMSFramework.cls-meta.xml b/force-app/main/default/classes/Bridge/CMSFramework.cls-meta.xml new file mode 100644 index 0000000..dd61d1f --- /dev/null +++ b/force-app/main/default/classes/Bridge/CMSFramework.cls-meta.xml @@ -0,0 +1,5 @@ + + + 52.0 + Active + diff --git a/force-app/main/default/classes/Bridge/ITheme.cls b/force-app/main/default/classes/Bridge/ITheme.cls new file mode 100644 index 0000000..0ef76b7 --- /dev/null +++ b/force-app/main/default/classes/Bridge/ITheme.cls @@ -0,0 +1,11 @@ +/** + * Created by bjohnson on 1/19/23. + */ + +public interface ITheme { + + void styleHeader(); + void styleFooter(); + void styleMenu(); + void styleContent(); +} \ No newline at end of file diff --git a/force-app/main/default/classes/Bridge/ITheme.cls-meta.xml b/force-app/main/default/classes/Bridge/ITheme.cls-meta.xml new file mode 100644 index 0000000..dd61d1f --- /dev/null +++ b/force-app/main/default/classes/Bridge/ITheme.cls-meta.xml @@ -0,0 +1,5 @@ + + + 52.0 + Active + diff --git a/force-app/main/default/classes/Bridge/Theme_WhiteBlue.cls b/force-app/main/default/classes/Bridge/Theme_WhiteBlue.cls new file mode 100644 index 0000000..364a22e --- /dev/null +++ b/force-app/main/default/classes/Bridge/Theme_WhiteBlue.cls @@ -0,0 +1,27 @@ +/** + * Created by bjohnson on 1/19/23. + */ + +public with sharing class Theme_WhiteBlue implements ITheme { + + + public void styleHeader() { + System.debug('Header font size : 16 px'); + System.debug('Background: Blue, Color: black'); + } + + public void styleFooter() { + System.debug('Footer - font size : 14 px'); + System.debug('Background : White, Color: blue'); + } + + public void styleMenu() { + System.debug('Menu - font size : 12 px'); + System.debug('Background : blue, Color: white'); + } + + public void styleContent() { + System.debug('Content - font size : 16px'); + System.debug('Background : white, Color: blue'); + } +} \ No newline at end of file diff --git a/force-app/main/default/classes/Bridge/Theme_WhiteBlue.cls-meta.xml b/force-app/main/default/classes/Bridge/Theme_WhiteBlue.cls-meta.xml new file mode 100644 index 0000000..dd61d1f --- /dev/null +++ b/force-app/main/default/classes/Bridge/Theme_WhiteBlue.cls-meta.xml @@ -0,0 +1,5 @@ + + + 52.0 + Active + diff --git a/force-app/main/default/classes/Bridge/Theme_WhiteGreen.cls b/force-app/main/default/classes/Bridge/Theme_WhiteGreen.cls new file mode 100644 index 0000000..1c0b9b4 --- /dev/null +++ b/force-app/main/default/classes/Bridge/Theme_WhiteGreen.cls @@ -0,0 +1,27 @@ +/** + * Created by bjohnson on 1/19/23. + */ + +public with sharing class Theme_WhiteGreen implements ITheme { + + + public void styleHeader() { + System.debug('Header - font size : 16px'); + System.debug('Background : Green, Color : Black'); + } + + public void styleFooter() { + System.debug('Footer - font size : 14px'); + System.debug('Background : White, Color : Green'); + } + + public void styleMenu() { + System.debug('Footer, Font size : 14px'); + System.debug('Background : White, Color : Green'); + } + + public void styleContent() { + System.debug('menu - font size : 14px'); + System.debug('Background : White, Color : Green'); + } +} \ No newline at end of file diff --git a/force-app/main/default/classes/Bridge/Theme_WhiteGreen.cls-meta.xml b/force-app/main/default/classes/Bridge/Theme_WhiteGreen.cls-meta.xml new file mode 100644 index 0000000..dd61d1f --- /dev/null +++ b/force-app/main/default/classes/Bridge/Theme_WhiteGreen.cls-meta.xml @@ -0,0 +1,5 @@ + + + 52.0 + Active + diff --git a/force-app/main/default/classes/Bridge/WebFramework.cls b/force-app/main/default/classes/Bridge/WebFramework.cls new file mode 100644 index 0000000..6e04dd0 --- /dev/null +++ b/force-app/main/default/classes/Bridge/WebFramework.cls @@ -0,0 +1,43 @@ +/** + * Created by bjohnson on 1/20/23. + */ + +public with sharing abstract class WebFramework { + + protected ITheme theme; + private String title; + private String keyword; + private String content; + + public WebFramework(ITheme theme){ + this.theme = theme; + } + + //concrete web framework must implement this + public abstract void capability(); + + private void setProperties(String title, String keyword, String content){ + this.title = title; + this.keyword = keyword; + this.content = content; + } + + private void printTitle() { + System.debug('Title: ' + this.title); + } + + private void printKeyword() { + system.debug('Keyword: ' + this.keyword); + } + + public virtual void showHeader_Footer(){ + this.theme.styleHeader(); + this.theme.styleFooter(); + } + + public virtual void showMenuBody(){ + this.theme.styleMenu(); + this.theme.styleContent(); + } + +} \ No newline at end of file diff --git a/force-app/main/default/classes/Bridge/WebFramework.cls-meta.xml b/force-app/main/default/classes/Bridge/WebFramework.cls-meta.xml new file mode 100644 index 0000000..dd61d1f --- /dev/null +++ b/force-app/main/default/classes/Bridge/WebFramework.cls-meta.xml @@ -0,0 +1,5 @@ + + + 52.0 + Active + diff --git a/force-app/main/default/classes/Builder/UserBuilder.cls b/force-app/main/default/classes/Builder/UserBuilder.cls index 8992e38..7d5ee6d 100644 --- a/force-app/main/default/classes/Builder/UserBuilder.cls +++ b/force-app/main/default/classes/Builder/UserBuilder.cls @@ -3,7 +3,6 @@ */ public with sharing class UserBuilder { - public with sharing class Admin implements IUserBuilder { public User user { get; private set; } diff --git a/package-lock.json b/package-lock.json index a098f96..9784038 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10990,6 +10990,20 @@ "is-typedarray": "^1.0.0" } }, + "node_modules/typescript": { + "version": "4.9.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz", + "integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==", + "dev": true, + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/unbox-primitive": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", @@ -19868,6 +19882,13 @@ "is-typedarray": "^1.0.0" } }, + "typescript": { + "version": "4.9.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz", + "integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==", + "dev": true, + "peer": true + }, "unbox-primitive": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz",