From 07db1e4678e6d9016ffb022ed42b5a1666098200 Mon Sep 17 00:00:00 2001 From: Kevin Knight <57677197+kevin-m-knight-gs@users.noreply.github.com> Date: Fri, 26 Jan 2024 11:57:41 -0500 Subject: [PATCH] Allow supplying EntityToPureConverter to PureModelBuilder (#746) --- .../pure/compiler/toPureGraph/PureModelBuilder.java | 13 ++++++++++--- .../pure/v1/PureModelContextDataBuilder.java | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/legend-sdlc-language-pure-compiler/src/main/java/org/finos/legend/sdlc/language/pure/compiler/toPureGraph/PureModelBuilder.java b/legend-sdlc-language-pure-compiler/src/main/java/org/finos/legend/sdlc/language/pure/compiler/toPureGraph/PureModelBuilder.java index e6751db361..e7a59c745e 100644 --- a/legend-sdlc-language-pure-compiler/src/main/java/org/finos/legend/sdlc/language/pure/compiler/toPureGraph/PureModelBuilder.java +++ b/legend-sdlc-language-pure-compiler/src/main/java/org/finos/legend/sdlc/language/pure/compiler/toPureGraph/PureModelBuilder.java @@ -24,6 +24,7 @@ import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.PackageableElement; import org.finos.legend.engine.shared.core.deployment.DeploymentMode; import org.finos.legend.sdlc.domain.model.entity.Entity; +import org.finos.legend.sdlc.protocol.pure.v1.EntityToPureConverter; import org.finos.legend.sdlc.protocol.pure.v1.PureModelContextDataBuilder; import java.util.ServiceLoader; @@ -31,13 +32,14 @@ public class PureModelBuilder { - private final PureModelContextDataBuilder contextDataBuilder = PureModelContextDataBuilder.newBuilder(); + private final PureModelContextDataBuilder contextDataBuilder; private ClassLoader classLoader; private CompilerExtensions extensions; private String packagePrefix; - private PureModelBuilder() + private PureModelBuilder(EntityToPureConverter converter) { + this.contextDataBuilder = PureModelContextDataBuilder.newBuilder(converter); } public int getElementCount() @@ -230,7 +232,12 @@ private CompilerExtensions getExtensions() public static PureModelBuilder newBuilder() { - return new PureModelBuilder(); + return newBuilder(null); + } + + public static PureModelBuilder newBuilder(EntityToPureConverter converter) + { + return new PureModelBuilder(converter); } public static class PureModelWithContextData diff --git a/legend-sdlc-protocol-pure/src/main/java/org/finos/legend/sdlc/protocol/pure/v1/PureModelContextDataBuilder.java b/legend-sdlc-protocol-pure/src/main/java/org/finos/legend/sdlc/protocol/pure/v1/PureModelContextDataBuilder.java index e8dbd1db57..bfa4d44242 100644 --- a/legend-sdlc-protocol-pure/src/main/java/org/finos/legend/sdlc/protocol/pure/v1/PureModelContextDataBuilder.java +++ b/legend-sdlc-protocol-pure/src/main/java/org/finos/legend/sdlc/protocol/pure/v1/PureModelContextDataBuilder.java @@ -36,7 +36,7 @@ public class PureModelContextDataBuilder private PureModelContextDataBuilder(EntityToPureConverter converter) { - this.converter = converter; + this.converter = (converter == null) ? new EntityToPureConverter() : converter; } public int getElementCount() @@ -192,7 +192,7 @@ public PureModelContextData build() public static PureModelContextDataBuilder newBuilder() { - return newBuilder(new EntityToPureConverter()); + return newBuilder(null); } public static PureModelContextDataBuilder newBuilder(EntityToPureConverter converter)