From 894247990dcf9163118add1d69177852057bcb4e Mon Sep 17 00:00:00 2001 From: anchita-g <109063673+anchita-g@users.noreply.github.com> Date: Fri, 15 Sep 2023 09:54:19 +0530 Subject: [PATCH] Adding factories --- .../fhir/sync/upload/patch/PatchGenerator.kt | 15 ++++++++------- .../fhir/sync/upload/patch/PatchGeneratorMode.kt | 3 +++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/engine/src/main/java/com/google/android/fhir/sync/upload/patch/PatchGenerator.kt b/engine/src/main/java/com/google/android/fhir/sync/upload/patch/PatchGenerator.kt index c0ecd39af0..2aa4cb823c 100644 --- a/engine/src/main/java/com/google/android/fhir/sync/upload/patch/PatchGenerator.kt +++ b/engine/src/main/java/com/google/android/fhir/sync/upload/patch/PatchGenerator.kt @@ -34,13 +34,14 @@ internal interface PatchGenerator { * certain numbers of [Patch]es. */ fun generate(localChanges: List): List +} - companion object { - internal fun byMode(mode: PatchGeneratorMode): PatchGenerator { - return when (mode) { - is PatchGeneratorMode.PerChange -> PerChangePatchGenerator - is PatchGeneratorMode.PerResource -> PerResourcePatchGenerator - } +internal object PatchGeneratorFactory { + fun byMode( + mode: PatchGeneratorMode, + ): PatchGenerator = + when (mode) { + is PatchGeneratorMode.PerChange -> PerChangePatchGenerator + is PatchGeneratorMode.PerResource -> PerResourcePatchGenerator } - } } diff --git a/engine/src/main/java/com/google/android/fhir/sync/upload/patch/PatchGeneratorMode.kt b/engine/src/main/java/com/google/android/fhir/sync/upload/patch/PatchGeneratorMode.kt index 678b5e0e97..1c37f8921a 100644 --- a/engine/src/main/java/com/google/android/fhir/sync/upload/patch/PatchGeneratorMode.kt +++ b/engine/src/main/java/com/google/android/fhir/sync/upload/patch/PatchGeneratorMode.kt @@ -16,6 +16,9 @@ package com.google.android.fhir.sync.upload.patch +/** + * Mode to decide the type of [PatchGenerator] that needs to be used to upload the [LocalChange]s + */ internal sealed class PatchGeneratorMode { object PerResource : PatchGeneratorMode()