From dd919a32bd155c787babe14ca14d0df8098d1432 Mon Sep 17 00:00:00 2001 From: Andreas Zerbst Date: Fri, 25 Aug 2023 15:23:01 +0200 Subject: [PATCH 1/4] Added an index for the dictionaryBuilder --- lib/builders/dictionary/index.ts | 2 ++ lib/builders/index.ts | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 lib/builders/dictionary/index.ts diff --git a/lib/builders/dictionary/index.ts b/lib/builders/dictionary/index.ts new file mode 100644 index 0000000..caf59e6 --- /dev/null +++ b/lib/builders/dictionary/index.ts @@ -0,0 +1,2 @@ +export {DictionaryBuilder} from './dictionaryBuilder'; +export {DictionaryTranslationBuilder} from './dictionaryTranslationBuilder'; \ No newline at end of file diff --git a/lib/builders/index.ts b/lib/builders/index.ts index 5d2c689..9ff9337 100644 --- a/lib/builders/index.ts +++ b/lib/builders/index.ts @@ -1,2 +1,3 @@ export * from './packages'; -export * from './dataTypes'; \ No newline at end of file +export * from './dataTypes'; +export * from './dictionary'; \ No newline at end of file From dadaffc7239ad5727bed0133762e2dbfae69f3d8 Mon Sep 17 00:00:00 2001 From: Andreas Zerbst Date: Fri, 25 Aug 2023 15:23:17 +0200 Subject: [PATCH 2/4] Created a dictionaryBuilder.ts --- lib/builders/dictionary/dictionaryBuilder.ts | 37 ++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 lib/builders/dictionary/dictionaryBuilder.ts diff --git a/lib/builders/dictionary/dictionaryBuilder.ts b/lib/builders/dictionary/dictionaryBuilder.ts new file mode 100644 index 0000000..def5236 --- /dev/null +++ b/lib/builders/dictionary/dictionaryBuilder.ts @@ -0,0 +1,37 @@ +import {DictionaryTranslationBuilder} from "./dictionaryTranslationBuilder"; + +export class DictionaryBuilder { + name: string; + parentId: string; + dictionaryTranslationBuilder; + + constructor() { + this.dictionaryTranslationBuilder = []; + } + + withName(name: string) { + this.name = name; + return this; + } + + addTranslation() { + const builder = new DictionaryTranslationBuilder(this); + this.dictionaryTranslationBuilder.push(builder); + return builder; + } + + withParentId(parentId: string) { + this.parentId = parentId; + return this; + } + + build() { + return { + name: this.name || undefined, + translations: this.dictionaryTranslationBuilder.map(builder => { + return builder.build(); + }), + parentId: this.parentId || undefined + } + } +} \ No newline at end of file From a195322a3b32e8085130e52c0ca6181289b1ebfe Mon Sep 17 00:00:00 2001 From: Andreas Zerbst Date: Fri, 25 Aug 2023 15:23:40 +0200 Subject: [PATCH 3/4] Created a dictionaryTranslationBuilder, which takes cares of all the translations --- .../dictionaryTranslationBuilder.ts | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 lib/builders/dictionary/dictionaryTranslationBuilder.ts diff --git a/lib/builders/dictionary/dictionaryTranslationBuilder.ts b/lib/builders/dictionary/dictionaryTranslationBuilder.ts new file mode 100644 index 0000000..850f1be --- /dev/null +++ b/lib/builders/dictionary/dictionaryTranslationBuilder.ts @@ -0,0 +1,32 @@ +import {DictionaryBuilder} from "./dictionaryBuilder"; + +export class DictionaryTranslationBuilder { + isoCode: string; + translation: string; + parentBuilder: DictionaryBuilder; + + constructor(parentBuilder: DictionaryBuilder) { + this.parentBuilder = parentBuilder + } + + withIsoCode(isoCode: string) { + this.isoCode = isoCode; + return this; + } + + withTranslation(translation: string) { + this.translation = translation; + return this; + } + + done() { + return this.parentBuilder; + } + + build() { + return { + isoCode: this.isoCode || "", + translation: this.translation || "" + } + } +} \ No newline at end of file From 91cc222120e446d8b9cee0512815793996db39f8 Mon Sep 17 00:00:00 2001 From: Andreas Zerbst Date: Fri, 25 Aug 2023 15:29:57 +0200 Subject: [PATCH 4/4] Updated naming --- lib/builders/{dictionary => dictionaries}/dictionaryBuilder.ts | 0 .../dictionaryTranslationBuilder.ts | 0 lib/builders/{dictionary => dictionaries}/index.ts | 0 lib/builders/index.ts | 2 +- 4 files changed, 1 insertion(+), 1 deletion(-) rename lib/builders/{dictionary => dictionaries}/dictionaryBuilder.ts (100%) rename lib/builders/{dictionary => dictionaries}/dictionaryTranslationBuilder.ts (100%) rename lib/builders/{dictionary => dictionaries}/index.ts (100%) diff --git a/lib/builders/dictionary/dictionaryBuilder.ts b/lib/builders/dictionaries/dictionaryBuilder.ts similarity index 100% rename from lib/builders/dictionary/dictionaryBuilder.ts rename to lib/builders/dictionaries/dictionaryBuilder.ts diff --git a/lib/builders/dictionary/dictionaryTranslationBuilder.ts b/lib/builders/dictionaries/dictionaryTranslationBuilder.ts similarity index 100% rename from lib/builders/dictionary/dictionaryTranslationBuilder.ts rename to lib/builders/dictionaries/dictionaryTranslationBuilder.ts diff --git a/lib/builders/dictionary/index.ts b/lib/builders/dictionaries/index.ts similarity index 100% rename from lib/builders/dictionary/index.ts rename to lib/builders/dictionaries/index.ts diff --git a/lib/builders/index.ts b/lib/builders/index.ts index 9ff9337..a0a1930 100644 --- a/lib/builders/index.ts +++ b/lib/builders/index.ts @@ -1,3 +1,3 @@ export * from './packages'; export * from './dataTypes'; -export * from './dictionary'; \ No newline at end of file +export * from './dictionaries';